1 /* 2 * Copyright (C) 2018 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 /** 18 * @addtogroup NdkBinder 19 * @{ 20 */ 21 22 /** 23 * @file binder_ibinder_jni.h 24 * @brief Conversions between AIBinder and android.os.IBinder 25 */ 26 27 #pragma once 28 29 #include <android/binder_ibinder.h> 30 31 #include <jni.h> 32 33 __BEGIN_DECLS 34 #if __ANDROID_API__ >= __ANDROID_API_Q__ 35 36 /** 37 * Converts an android.os.IBinder object into an AIBinder* object. 38 * 39 * If either env or the binder is null, null is returned. If this binder object was originally an 40 * AIBinder object, the original object is returned. The returned object has one refcount 41 * associated with it, and so this should be accompanied with an AIBinder_decStrong call. 42 * 43 * \param env Java environment. 44 * \param binder android.os.IBinder java object. 45 * 46 * \return an AIBinder object representing the Java binder object. If either parameter is null, or 47 * the Java object is of the wrong type, this will return null. 48 */ 49 __attribute__((warn_unused_result)) AIBinder* AIBinder_fromJavaBinder(JNIEnv* env, jobject binder) 50 __INTRODUCED_IN(29); 51 52 /** 53 * Converts an AIBinder* object into an android.os.IBinder object. 54 * 55 * If either env or the binder is null, null is returned. If this binder object was originally an 56 * IBinder object, the original java object will be returned. 57 * 58 * \param env Java environment. 59 * \param binder the object to convert. 60 * 61 * \return an android.os.IBinder object or null if the parameters were null. 62 */ 63 __attribute__((warn_unused_result)) jobject AIBinder_toJavaBinder(JNIEnv* env, AIBinder* binder) 64 __INTRODUCED_IN(29); 65 66 #endif //__ANDROID_API__ >= __ANDROID_API_Q__ 67 __END_DECLS 68 69 /** @} */ 70