• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #pragma once
18 
19 #if (!defined(__ANDROID_APEX__) && !defined(__ANDROID_VNDK__)) || defined(__TRUSTY__)
20 
21 #include <android/binder_ibinder.h>
22 #include <android/binder_parcel.h>
23 #include <binder/IBinder.h>
24 #include <binder/Parcel.h>
25 
26 /**
27  * Get libbinder version of binder from AIBinder.
28  *
29  * WARNING: function calls to a local object on the other side of this function
30  * will parcel. When converting between binders, keep in mind it is not as
31  * efficient as a direct function call.
32  *
33  * \param binder binder with ownership retained by the client
34  * \return platform binder object
35  */
36 android::sp<android::IBinder> AIBinder_toPlatformBinder(AIBinder* binder);
37 
38 /**
39  * Get libbinder_ndk version of binder from platform binder.
40  *
41  * WARNING: function calls to a local object on the other side of this function
42  * will parcel. When converting between binders, keep in mind it is not as
43  * efficient as a direct function call.
44  *
45  * \param binder platform binder which may be from anywhere (doesn't have to be
46  * created with libbinder_ndK)
47  * \return binder with one reference count of ownership given to the client. See
48  * AIBinder_decStrong
49  */
50 AIBinder* AIBinder_fromPlatformBinder(const android::sp<android::IBinder>& binder);
51 
52 /**
53  * View libbinder version of parcel from AParcel (mutable).
54  *
55  * The lifetime of the returned parcel is the lifetime of the input AParcel.
56  * Do not ues this reference after dropping the AParcel.
57  *
58  * \param parcel non-null parcel with ownership retained by client
59  * \return platform parcel object
60  */
61 android::Parcel* AParcel_viewPlatformParcel(AParcel* parcel);
62 
63 /**
64  * View libbinder version of parcel from AParcel (const version).
65  *
66  * The lifetime of the returned parcel is the lifetime of the input AParcel.
67  * Do not ues this reference after dropping the AParcel.
68  *
69  * \param parcel non-null parcel with ownership retained by client
70  * \return platform parcel object
71  */
72 const android::Parcel* AParcel_viewPlatformParcel(const AParcel* parcel);
73 
74 #endif
75