• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #[repr(C)]
21 pub struct CRemoteObject {
22     _private: [u8; 0],
23 }
24 
25 #[repr(C)]
26 pub struct CDeathRecipient {
27     _private: [u8; 0],
28 }
29 
30 #[repr(C)]
31 pub struct CParcel {
32     _private: [u8; 0],
33 }
34 
35 #[repr(C)]
36 pub struct CAshmem {
37     _private: [u8; 0],
38 }
39 
40 // Callback function type for OnRemoteRequest() from native, this
41 // callback will be called when native recive client IPC request.
42 pub type OnRemoteRequest = unsafe extern "C" fn (
43     user_data: *mut c_void,
44     code: u32,
45     data: *const CParcel,
46     reply: *mut CParcel
47 ) -> i32;
48 
49 // Callback function type for OnRemoteDump() from native, this
50 // callback will be called when native recive client IPC dump.
51 pub type OnRemoteDump = unsafe extern "C" fn (
52     user_data: *mut c_void,
53     data: *const CParcel,
54 ) -> i32;
55 
56 // Callback function type for OnRemoteObjectDestroy() from native,
57 // this callback will be called when native remote object destroyed.
58 pub type OnRemoteObjectDestroy = unsafe extern "C" fn (
59     user_data: *mut c_void
60 );
61 
62 // Callback function type for OnDeathRecipientCb() from native,
63 // this callback will be called when remote stub is destroyed.
64 pub type OnDeathRecipientCb = unsafe extern "C" fn (
65     callback: *mut c_void
66 );
67 
68 // Callback function type for OnDeathRecipientDestroyCb() from native,
69 // this callback will be called when native CDeathRecipient destroyed.
70 pub type OnDeathRecipientDestroyCb = unsafe extern "C" fn (
71     callback: *mut c_void
72 );
73 
74 // Callback function type for OnCParcelBytesAllocator() from native,
75 // this callback will be called when native parcel need allocate buffer
76 // for string or bytes buffer by rust.
77 pub type OnCParcelBytesAllocator<T> = unsafe extern "C" fn (
78     value: *mut c_void,
79     buffer: *mut *mut T,
80     len: i32
81 ) -> bool;
82 
83 pub type OnCParcelAllocator = unsafe extern "C" fn (
84     value: *mut c_void,
85     len: i32
86 ) -> bool;
87 
88 // Callback function type for CParcelReadStringArray() from native.
89 // Rust side need read string one by one from native according calling
90 // CParcelReadStringElement().
91 pub type OnStringArrayRead = unsafe extern "C" fn(
92     data: *const c_void, // C++ vector pointer
93     value: *mut c_void, // Rust vector pointer
94     len: u32 // C++ vector length
95 ) -> bool;
96 
97 // Callback function type for CParcelReadString16Array() from native.
98 // Rust side need read string one by one from native according calling
99 // CParcelReadString16Element().
100 pub type OnString16ArrayRead = unsafe extern "C" fn(
101     data: *const c_void, // C++ vector pointer
102     value: *mut c_void, // Rust vector pointer
103     len: u32 // C++ vector length
104 ) -> bool;
105 
106 // Callback function type for CParcelWriteStringArray() from native.
107 // Rust side need write string one by one to native according calling
108 // CParcelWriteStringElement().
109 pub type OnStringArrayWrite = unsafe extern "C" fn(
110     array: *const c_void, // C++ vector pointer
111     value: *mut c_void, // Rust vector pointer
112     len: u32, // Rust vector length
113 ) -> bool;
114 
115 // Callback function type for CParcelWriteString16Array() from native.
116 // Rust side need write string one by one to native according calling
117 // CParcelWriteString16Element().
118 pub type OnString16ArrayWrite = unsafe extern "C" fn(
119     array: *const c_void, // C++ vector pointer
120     value: *mut c_void, // Rust vector pointer
121     len: u32, // Rust vector length
122 ) -> bool;
123 
124 pub type OnCParcelWriteElement = unsafe extern "C" fn (
125     value: *mut CParcel,
126     arr: *const c_void,
127     index: c_ulong,
128 ) -> bool;
129 
130 pub type OnCParcelReadElement = unsafe extern "C" fn (
131     value: *const CParcel,
132     arr: *mut c_void,
133     index: c_ulong,
134 ) -> bool;
135 
136 // C interface for IPC core object
137 extern "C" {
CreateRemoteStub(descripor: *const c_char, on_remote_request: OnRemoteRequest, on_remote_object_destroy: OnRemoteObjectDestroy, user_data: *const c_void, on_remote_dump: OnRemoteDump) -> *mut CRemoteObject138     pub fn CreateRemoteStub(descripor: *const c_char, on_remote_request: OnRemoteRequest,
139         on_remote_object_destroy: OnRemoteObjectDestroy,
140         user_data: *const c_void, on_remote_dump: OnRemoteDump) -> *mut CRemoteObject;
RemoteObjectIncStrongRef(object: *mut CRemoteObject)141     pub fn RemoteObjectIncStrongRef(object: *mut CRemoteObject);
RemoteObjectDecStrongRef(object: *mut CRemoteObject)142     pub fn RemoteObjectDecStrongRef(object: *mut CRemoteObject);
143 
RemoteObjectSendRequest(object: *mut CRemoteObject, code: u32, data: *const CParcel, reply: *mut CParcel, is_async: bool) -> i32144     pub fn RemoteObjectSendRequest(object: *mut CRemoteObject, code: u32,
145         data: *const CParcel, reply: *mut CParcel, is_async: bool) -> i32;
RemoteObjectLessThan(object: *const CRemoteObject, other: *const CRemoteObject) -> bool146     pub fn RemoteObjectLessThan(object: *const CRemoteObject,
147         other: *const CRemoteObject) -> bool;
148 
CreateDeathRecipient(onDeathRecipient: OnDeathRecipientCb, onDestroy: OnDeathRecipientDestroyCb, userData: *const c_void) -> *mut CDeathRecipient149     pub fn CreateDeathRecipient(onDeathRecipient: OnDeathRecipientCb,
150         onDestroy: OnDeathRecipientDestroyCb,
151         userData: *const c_void) -> *mut CDeathRecipient;
DeathRecipientDecStrongRef(recipient: *mut CDeathRecipient)152     pub fn DeathRecipientDecStrongRef(recipient: *mut CDeathRecipient);
AddDeathRecipient(object: *mut CRemoteObject, recipient: *mut CDeathRecipient) -> bool153     pub fn AddDeathRecipient(object: *mut CRemoteObject,
154         recipient: *mut CDeathRecipient) -> bool;
RemoveDeathRecipient(object: *mut CRemoteObject, recipient: *mut CDeathRecipient) -> bool155     pub fn RemoveDeathRecipient(object: *mut CRemoteObject,
156         recipient: *mut CDeathRecipient) -> bool;
157 
IsProxyObject(object: *mut CRemoteObject) -> bool158     pub fn IsProxyObject(object: *mut CRemoteObject) -> bool;
Dump(object: *mut CRemoteObject, fd: i32, parcel: *mut CParcel) -> i32159     pub fn Dump(object: *mut CRemoteObject, fd: i32, parcel: *mut CParcel) -> i32;
160 
IsObjectDead(object: *mut CRemoteObject) -> bool161     pub fn IsObjectDead(object: *mut CRemoteObject) -> bool;
GetInterfaceDescriptor(object: *mut CRemoteObject, value: *mut c_void, allocator: OnCParcelBytesAllocator::<u16>) -> bool162     pub fn GetInterfaceDescriptor(object: *mut CRemoteObject,
163         value: *mut c_void, allocator: OnCParcelBytesAllocator::<u16>) -> bool;
164 }
165 
166 // C interface for Parcel
167 extern "C" {
CParcelObtain() -> *mut CParcel168     pub fn CParcelObtain() -> *mut CParcel;
CParcelDecStrongRef(parcel: *mut CParcel)169     pub fn CParcelDecStrongRef(parcel: *mut CParcel);
170 
CParcelWriteBool(parcel: *mut CParcel, value: bool) -> bool171     pub fn CParcelWriteBool(parcel: *mut CParcel, value: bool) -> bool;
CParcelReadBool(parcel: *const CParcel, value: *mut bool) -> bool172     pub fn CParcelReadBool(parcel: *const CParcel, value: *mut bool) -> bool;
CParcelWriteInt8(parcel: *mut CParcel, value: i8) -> bool173     pub fn CParcelWriteInt8(parcel: *mut CParcel, value: i8) -> bool;
CParcelReadInt8(parcel: *const CParcel, value: *mut i8) -> bool174     pub fn CParcelReadInt8(parcel: *const CParcel, value: *mut i8) -> bool;
CParcelWriteInt16(parcel: *mut CParcel, value: i16) -> bool175     pub fn CParcelWriteInt16(parcel: *mut CParcel, value: i16) -> bool;
CParcelReadInt16(parcel: *const CParcel, value: *mut i16) -> bool176     pub fn CParcelReadInt16(parcel: *const CParcel, value: *mut i16) -> bool;
CParcelWriteInt32(parcel: *mut CParcel, value: i32) -> bool177     pub fn CParcelWriteInt32(parcel: *mut CParcel, value: i32) -> bool;
CParcelReadInt32(parcel: *const CParcel, value: *mut i32) -> bool178     pub fn CParcelReadInt32(parcel: *const CParcel, value: *mut i32) -> bool;
CParcelWriteInt64(parcel: *mut CParcel, value: i64) -> bool179     pub fn CParcelWriteInt64(parcel: *mut CParcel, value: i64) -> bool;
CParcelReadInt64(parcel: *const CParcel, value: *mut i64) -> bool180     pub fn CParcelReadInt64(parcel: *const CParcel, value: *mut i64) -> bool;
CParcelWriteFloat(parcel: *mut CParcel, value: f32) -> bool181     pub fn CParcelWriteFloat(parcel: *mut CParcel, value: f32) -> bool;
CParcelReadFloat(parcel: *const CParcel, value: *mut f32) -> bool182     pub fn CParcelReadFloat(parcel: *const CParcel, value: *mut f32) -> bool;
CParcelWriteDouble(parcel: *mut CParcel, value: f64) -> bool183     pub fn CParcelWriteDouble(parcel: *mut CParcel, value: f64) -> bool;
CParcelReadDouble(parcel: *const CParcel, value: *mut f64) -> bool184     pub fn CParcelReadDouble(parcel: *const CParcel, value: *mut f64) -> bool;
CParcelWriteString(parcel: *mut CParcel, value: *const c_char, len: i32) -> bool185     pub fn CParcelWriteString(parcel: *mut CParcel, value: *const c_char, len: i32) -> bool;
CParcelReadString(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool186     pub fn CParcelReadString(parcel: *const CParcel, value: *mut c_void,
187         allocator: OnCParcelBytesAllocator::<u8>) -> bool;
CParcelWriteString16(parcel: *mut CParcel, value: *const c_char, len: i32) -> bool188     pub fn CParcelWriteString16(parcel: *mut CParcel, value: *const c_char, len: i32) -> bool;
CParcelReadString16(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool189     pub fn CParcelReadString16(parcel: *const CParcel, value: *mut c_void,
190         allocator: OnCParcelBytesAllocator::<u8>) -> bool;
CParcelWriteInterfaceToken(parcel: *mut CParcel, token: *const c_char, len: i32) -> bool191     pub fn CParcelWriteInterfaceToken(parcel: *mut CParcel,
192         token: *const c_char, len: i32) -> bool;
CParcelReadInterfaceToken(parcel: *const CParcel, token: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool193     pub fn CParcelReadInterfaceToken(parcel: *const CParcel, token: *mut c_void,
194         allocator: OnCParcelBytesAllocator::<u8>) -> bool;
CParcelWriteRemoteObject(parcel: *mut CParcel, object: *mut CRemoteObject) -> bool195     pub fn CParcelWriteRemoteObject(parcel: *mut CParcel, object: *mut CRemoteObject) -> bool;
CParcelReadRemoteObject(parcel: *const CParcel) -> *mut CRemoteObject196     pub fn CParcelReadRemoteObject(parcel: *const CParcel) -> *mut CRemoteObject;
CParcelWriteBuffer(parcel: *mut CParcel, value: *const u8, len: u32) -> bool197     pub fn CParcelWriteBuffer(parcel: *mut CParcel, value: *const u8, len: u32) -> bool;
CParcelReadBuffer(parcel: *const CParcel, value: *mut u8, len: u32) -> bool198     pub fn CParcelReadBuffer(parcel: *const CParcel, value: *mut u8, len: u32) -> bool;
CParcelWriteRawData(parcel: *mut CParcel, value: *const u8, len: u32) -> bool199     pub fn CParcelWriteRawData(parcel: *mut CParcel, value: *const u8, len: u32) -> bool;
CParcelReadRawData(parcel: *const CParcel, len: u32) -> *mut u8200     pub fn CParcelReadRawData(parcel: *const CParcel,  len: u32) ->  *mut u8;
CParcelWriteFileDescriptor(parcel: *mut CParcel, fd: i32) -> bool201     pub fn CParcelWriteFileDescriptor(parcel: *mut CParcel, fd: i32) -> bool;
CParcelReadFileDescriptor(parcel: *const CParcel, fd: *mut i32) -> bool202     pub fn CParcelReadFileDescriptor(parcel: *const CParcel, fd: *mut i32) -> bool;
203 
CParcelWriteBoolArray(parcel: *mut CParcel, value: *const bool, len: i32) -> bool204     pub fn CParcelWriteBoolArray(parcel: *mut CParcel, value: *const bool, len: i32) -> bool;
CParcelReadBoolArray(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<bool>) -> bool205     pub fn CParcelReadBoolArray(parcel: *const CParcel, value: *mut c_void,
206         allocator: OnCParcelBytesAllocator::<bool>) -> bool;
CParcelWriteInt8Array(parcel: *mut CParcel, value: *const i8, len: i32) -> bool207     pub fn CParcelWriteInt8Array(parcel: *mut CParcel, value: *const i8, len: i32) -> bool;
CParcelReadInt8Array(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<i8>) -> bool208     pub fn CParcelReadInt8Array(parcel: *const CParcel, value: *mut c_void,
209         allocator: OnCParcelBytesAllocator::<i8>) -> bool;
CParcelWriteInt16Array(parcel: *mut CParcel, value: *const i16, len: i32) -> bool210     pub fn CParcelWriteInt16Array(parcel: *mut CParcel, value: *const i16, len: i32) -> bool;
CParcelReadInt16Array(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<i16>) -> bool211     pub fn CParcelReadInt16Array(parcel: *const CParcel, value: *mut c_void,
212         allocator: OnCParcelBytesAllocator::<i16>) -> bool;
CParcelWriteInt32Array(parcel: *mut CParcel, value: *const i32, len: i32) -> bool213     pub fn CParcelWriteInt32Array(parcel: *mut CParcel, value: *const i32, len: i32) -> bool;
CParcelReadInt32Array(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<i32>) -> bool214     pub fn CParcelReadInt32Array(parcel: *const CParcel, value: *mut c_void,
215         allocator: OnCParcelBytesAllocator::<i32>) -> bool;
CParcelWriteInt64Array(parcel: *mut CParcel, value: *const i64, len: i32) -> bool216     pub fn CParcelWriteInt64Array(parcel: *mut CParcel, value: *const i64, len: i32) -> bool;
CParcelReadInt64Array(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<i64>) -> bool217     pub fn CParcelReadInt64Array(parcel: *const CParcel, value: *mut c_void,
218         allocator: OnCParcelBytesAllocator::<i64>) -> bool;
CParcelWriteFloatArray(parcel: *mut CParcel, value: *const f32, len: i32) -> bool219     pub fn CParcelWriteFloatArray(parcel: *mut CParcel, value: *const f32, len: i32) -> bool;
CParcelReadFloatArray(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<f32>) -> bool220     pub fn CParcelReadFloatArray(parcel: *const CParcel, value: *mut c_void,
221         allocator: OnCParcelBytesAllocator::<f32>) -> bool;
CParcelWriteDoubleArray(parcel: *mut CParcel, value: *const f64, len: i32) -> bool222     pub fn CParcelWriteDoubleArray(parcel: *mut CParcel, value: *const f64, len: i32) -> bool;
CParcelReadDoubleArray(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<f64>) -> bool223     pub fn CParcelReadDoubleArray(parcel: *const CParcel, value: *mut c_void,
224         allocator: OnCParcelBytesAllocator::<f64>) -> bool;
CParcelWriteStringArray(parcel: *mut CParcel, value: *const c_void, len: i32, writer: OnStringArrayWrite) -> bool225     pub fn CParcelWriteStringArray(parcel: *mut CParcel, value: *const c_void, len: i32,
226         writer: OnStringArrayWrite) -> bool;
CParcelWriteString16Array(parcel: *mut CParcel, value: *const c_void, len: i32, writer: OnString16ArrayWrite) -> bool227     pub fn CParcelWriteString16Array(parcel: *mut CParcel, value: *const c_void, len: i32,
228         writer: OnString16ArrayWrite) -> bool;
CParcelWriteStringElement(data: *const c_void, value: *const c_char, len: i32) -> bool229     pub fn CParcelWriteStringElement(data: *const c_void, value: *const c_char,
230         len: i32) -> bool;
CParcelWritU16stringElement(data: *const c_void, value: *const c_char, len: i32) -> bool231     pub fn CParcelWritU16stringElement(data: *const c_void, value: *const c_char,
232         len: i32) -> bool;
CParcelReadStringArray(parcel: *const CParcel, value: *mut c_void, reader: OnStringArrayRead) -> bool233     pub fn CParcelReadStringArray(parcel: *const CParcel, value: *mut c_void,
234         reader: OnStringArrayRead) -> bool;
CParcelReadString16Array(parcel: *const CParcel, value: *mut c_void, reader: OnString16ArrayRead) -> bool235     pub fn CParcelReadString16Array(parcel: *const CParcel, value: *mut c_void,
236         reader: OnString16ArrayRead) -> bool;
CParcelReadStringElement(index: u32, data: *const c_void, value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool237     pub fn CParcelReadStringElement(index: u32, data: *const c_void, value: *mut c_void,
238         allocator: OnCParcelBytesAllocator::<u8>) -> bool;
CParcelReadString16Element(index: u32, data: *const c_void, value: *mut c_void, allocator: OnCParcelBytesAllocator::<u16>) -> bool239     pub fn CParcelReadString16Element(index: u32, data: *const c_void, value: *mut c_void,
240         allocator: OnCParcelBytesAllocator::<u16>) -> bool;
CParcelWriteParcelableArray(parcel: *mut CParcel, value: *const c_void, len: i32, element_writer: OnCParcelWriteElement) -> bool241     pub fn CParcelWriteParcelableArray(parcel: *mut CParcel, value: *const c_void, len: i32,
242         element_writer: OnCParcelWriteElement) -> bool;
CParcelReadParcelableArray(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelAllocator, element_reader: OnCParcelReadElement ) -> bool243     pub fn CParcelReadParcelableArray(parcel: *const CParcel, value: *mut c_void,
244         allocator: OnCParcelAllocator, element_reader: OnCParcelReadElement ) -> bool;
245 
CParcelGetDataSize(parcel: *const CParcel) -> u32246     pub fn CParcelGetDataSize(parcel: *const CParcel) -> u32;
CParcelSetDataSize(parcel: *mut CParcel, new_size: u32) -> bool247     pub fn CParcelSetDataSize(parcel: *mut CParcel, new_size: u32) -> bool;
CParcelGetDataCapacity(parcel: *const CParcel) -> u32248     pub fn CParcelGetDataCapacity(parcel: *const CParcel) -> u32;
CParcelSetDataCapacity(parcel: *mut CParcel, new_size: u32) -> bool249     pub fn CParcelSetDataCapacity(parcel: *mut CParcel, new_size: u32) -> bool;
CParcelGetMaxCapacity(parcel: *const CParcel) -> u32250     pub fn CParcelGetMaxCapacity(parcel: *const CParcel) -> u32;
CParcelSetMaxCapacity(parcel: *mut CParcel, new_size: u32) -> bool251     pub fn CParcelSetMaxCapacity(parcel: *mut CParcel, new_size: u32) -> bool;
CParcelGetWritableBytes(parcel: *const CParcel) -> u32252     pub fn CParcelGetWritableBytes(parcel: *const CParcel) -> u32;
CParcelGetReadableBytes(parcel: *const CParcel) -> u32253     pub fn CParcelGetReadableBytes(parcel: *const CParcel) -> u32;
CParcelGetReadPosition(parcel: *const CParcel) -> u32254     pub fn CParcelGetReadPosition(parcel: *const CParcel) -> u32;
CParcelGetWritePosition(parcel: *const CParcel) -> u32255     pub fn CParcelGetWritePosition(parcel: *const CParcel) -> u32;
CParcelRewindRead(parcel: *mut CParcel, new_pos: u32) -> bool256     pub fn CParcelRewindRead(parcel: *mut CParcel, new_pos: u32) -> bool;
CParcelRewindWrite(parcel: *mut CParcel, new_pos: u32) -> bool257     pub fn CParcelRewindWrite(parcel: *mut CParcel, new_pos: u32) -> bool;
CParcelWriteAshmem(parcel: *mut CParcel, ashmem: *mut CAshmem) -> bool258     pub fn CParcelWriteAshmem(parcel: *mut CParcel, ashmem: *mut CAshmem) -> bool;
CParcelReadAshmem(parcel: *const CParcel) -> *mut CAshmem259     pub fn CParcelReadAshmem(parcel: *const CParcel) -> *mut CAshmem;
260 
CParcelContainFileDescriptors(parcel: *const CParcel) -> bool261     pub fn CParcelContainFileDescriptors(parcel: *const CParcel) -> bool;
CParcelGetRawDataSize(parcel: *const CParcel) -> usize262     pub fn CParcelGetRawDataSize(parcel: *const CParcel) -> usize;
CParcelGetRawDataCapacity(parcel: *const CParcel) -> usize263     pub fn CParcelGetRawDataCapacity(parcel: *const CParcel) -> usize;
CParcelClearFileDescriptor(parcel: *mut CParcel)264     pub fn CParcelClearFileDescriptor(parcel: *mut CParcel);
CParcelSetClearFdFlag(parcel: *mut CParcel)265     pub fn CParcelSetClearFdFlag(parcel: *mut CParcel);
CParcelAppend(parcel: *mut CParcel, data: *mut CParcel) -> bool266     pub fn CParcelAppend(parcel: *mut CParcel, data: *mut CParcel) -> bool;
267 }
268 
269 // C interface for Ashmem
270 extern "C" {
CreateCAshmem(name: *const c_char, size: i32) -> *mut CAshmem271     pub fn CreateCAshmem(name: *const c_char, size: i32) -> *mut CAshmem;
CAshmemIncStrongRef(ashmem: *mut CAshmem)272     pub fn CAshmemIncStrongRef(ashmem: *mut CAshmem);
CAshmemDecStrongRef(ashmem: *mut CAshmem)273     pub fn CAshmemDecStrongRef(ashmem: *mut CAshmem);
274 
CloseCAshmem(ashmem: *mut CAshmem)275     pub fn CloseCAshmem(ashmem: *mut CAshmem);
MapCAshmem(ashmem: *mut CAshmem, mapType: i32) -> bool276     pub fn MapCAshmem(ashmem: *mut CAshmem, mapType: i32) -> bool;
MapReadAndWriteCAshmem(ashmem: *mut CAshmem) -> bool277     pub fn MapReadAndWriteCAshmem(ashmem: *mut CAshmem) -> bool;
MapReadOnlyCAshmem(ashmem: *mut CAshmem) -> bool278     pub fn MapReadOnlyCAshmem(ashmem: *mut CAshmem) -> bool;
UnmapCAshmem(ashmem: *mut CAshmem)279     pub fn UnmapCAshmem(ashmem: *mut CAshmem);
SetCAshmemProtection(ashmem: *mut CAshmem, protectionType: i32) -> bool280     pub fn SetCAshmemProtection(ashmem: *mut CAshmem, protectionType: i32) -> bool;
GetCAshmemProtection(ashmem: *const CAshmem) -> i32281     pub fn GetCAshmemProtection(ashmem: *const CAshmem) -> i32;
GetCAshmemSize(ashmem: *const CAshmem) -> i32282     pub fn GetCAshmemSize(ashmem: *const CAshmem) -> i32;
WriteToCAshmem(ashmem: *mut CAshmem, data: *const u8, size: i32, offset: i32) -> bool283     pub fn WriteToCAshmem(ashmem: *mut CAshmem, data: *const u8,
284         size: i32, offset: i32) -> bool;
ReadFromCAshmem(ashmem: *const CAshmem, size: i32, offset: i32) -> *const u8285     pub fn ReadFromCAshmem(ashmem: *const CAshmem, size: i32, offset: i32) -> *const u8;
GetCAshmemFd(ashmem: *const CAshmem) -> i32286     pub fn GetCAshmemFd(ashmem: *const CAshmem) -> i32;
287 }
288 
289 // C interface for IPC miscellaneous
290 extern "C" {
GetContextManager() -> *mut CRemoteObject291     pub fn GetContextManager() -> *mut CRemoteObject;
JoinWorkThread()292     pub fn JoinWorkThread();
StopWorkThread()293     pub fn StopWorkThread();
GetCallingTokenId() -> u64294     pub fn GetCallingTokenId() -> u64;
GetFirstToekenId() -> u64295     pub fn GetFirstToekenId() -> u64;
GetSelfToekenId() -> u64296     pub fn GetSelfToekenId() -> u64;
GetCallingPid() -> u64297     pub fn GetCallingPid() -> u64;
GetCallingUid() -> u64298     pub fn GetCallingUid() -> u64;
299 
SetMaxWorkThreadNum(maxThreadNum: i32) -> bool300     pub fn SetMaxWorkThreadNum(maxThreadNum: i32) -> bool;
IsLocalCalling() -> bool301     pub fn IsLocalCalling() -> bool;
SetCallingIdentity(identity: *const c_char) -> bool302     pub fn SetCallingIdentity(identity: *const c_char) -> bool;
GetLocalDeviceID(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool303     pub fn GetLocalDeviceID(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool;
GetCallingDeviceID(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool304     pub fn GetCallingDeviceID(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool;
ResetCallingIdentity(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool305     pub fn ResetCallingIdentity(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool;
306 }