Loading libs/binder/ndk/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ cc_library { srcs: [ "ibinder.cpp", "ibinder_jni.cpp", "parcel.cpp", "process.cpp", "status.cpp", Loading @@ -32,6 +33,7 @@ cc_library { ], shared_libs: [ "libandroid_runtime", "libbase", "libbinder", "libutils", Loading libs/binder/ndk/ibinder_jni.cpp 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <android/binder_ibinder_jni.h> #include "ibinder_internal.h" #include <android_util_Binder.h> using ::android::IBinder; using ::android::ibinderForJavaObject; using ::android::javaObjectForIBinder; using ::android::sp; AIBinder* AIBinder_fromJavaBinder(JNIEnv* env, jobject binder) { sp<IBinder> ibinder = ibinderForJavaObject(env, binder); sp<AIBinder> cbinder = ABpBinder::lookupOrCreateFromBinder(ibinder); AIBinder_incStrong(cbinder.get()); return cbinder.get(); } jobject AIBinder_toJavaBinder(JNIEnv* env, AIBinder* binder) { if (binder == nullptr) { return nullptr; } return javaObjectForIBinder(env, binder->getBinder()); } libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup NdkBinder * @{ */ /** * @file binder_ibinder_jni.h * @brief Conversions between AIBinder and android.os.IBinder */ #pragma once #include <android/binder_ibinder.h> #include <jni.h> __BEGIN_DECLS /** * Converts an android.os.IBinder object into an AIBinder* object. * * If either env or the binder is null, null is returned. If this binder object was originally an * AIBinder object, the original object is returned. The returned object has one refcount * associated with it, and so this should be accompanied with an AIBinder_decStrong call. */ __attribute__((warn_unused_result)) AIBinder* AIBinder_fromJavaBinder(JNIEnv* env, jobject binder); /** * Converts an AIBinder* object into an android.os.IBinder object. * * If either env or the binder is null, null is returned. If this binder object was originally an * IBinder object, the original java object will be returned. */ __attribute__((warn_unused_result)) jobject AIBinder_toJavaBinder(JNIEnv* env, AIBinder* binder); __END_DECLS /** @} */ libs/binder/ndk/libbinder_ndk.map.txt +2 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ LIBBINDER_NDK { # introduced=29 AIBinder_DeathRecipient_new; AIBinder_debugGetRefCount; AIBinder_decStrong; AIBinder_fromJavaBinder; AIBinder_getClass; AIBinder_getUserData; AIBinder_incStrong; Loading @@ -15,6 +16,7 @@ LIBBINDER_NDK { # introduced=29 AIBinder_new; AIBinder_ping; AIBinder_prepareTransaction; AIBinder_toJavaBinder; AIBinder_transact; AIBinder_unlinkToDeath; AIBinder_Weak_delete; Loading libs/binder/ndk/scripts/init_map.sh +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ echo "LIBBINDER_NDK { # introduced=29" echo " global:" { grep -oP "AIBinder_[a-zA-Z0-9_]+(?=\()" include_ndk/android/binder_ibinder.h; grep -oP "AIBinder_[a-zA-Z0-9_]+(?=\()" include_ndk/android/binder_ibinder_jni.h; grep -oP "AParcel_[a-zA-Z0-9_]+(?=\()" include_ndk/android/binder_parcel.h; grep -oP "AStatus_[a-zA-Z0-9_]+(?=\()" include_ndk/android/binder_status.h; } | sort | uniq | awk '{ print " " $0 ";"; }' Loading Loading
libs/binder/ndk/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ cc_library { srcs: [ "ibinder.cpp", "ibinder_jni.cpp", "parcel.cpp", "process.cpp", "status.cpp", Loading @@ -32,6 +33,7 @@ cc_library { ], shared_libs: [ "libandroid_runtime", "libbase", "libbinder", "libutils", Loading
libs/binder/ndk/ibinder_jni.cpp 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <android/binder_ibinder_jni.h> #include "ibinder_internal.h" #include <android_util_Binder.h> using ::android::IBinder; using ::android::ibinderForJavaObject; using ::android::javaObjectForIBinder; using ::android::sp; AIBinder* AIBinder_fromJavaBinder(JNIEnv* env, jobject binder) { sp<IBinder> ibinder = ibinderForJavaObject(env, binder); sp<AIBinder> cbinder = ABpBinder::lookupOrCreateFromBinder(ibinder); AIBinder_incStrong(cbinder.get()); return cbinder.get(); } jobject AIBinder_toJavaBinder(JNIEnv* env, AIBinder* binder) { if (binder == nullptr) { return nullptr; } return javaObjectForIBinder(env, binder->getBinder()); }
libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup NdkBinder * @{ */ /** * @file binder_ibinder_jni.h * @brief Conversions between AIBinder and android.os.IBinder */ #pragma once #include <android/binder_ibinder.h> #include <jni.h> __BEGIN_DECLS /** * Converts an android.os.IBinder object into an AIBinder* object. * * If either env or the binder is null, null is returned. If this binder object was originally an * AIBinder object, the original object is returned. The returned object has one refcount * associated with it, and so this should be accompanied with an AIBinder_decStrong call. */ __attribute__((warn_unused_result)) AIBinder* AIBinder_fromJavaBinder(JNIEnv* env, jobject binder); /** * Converts an AIBinder* object into an android.os.IBinder object. * * If either env or the binder is null, null is returned. If this binder object was originally an * IBinder object, the original java object will be returned. */ __attribute__((warn_unused_result)) jobject AIBinder_toJavaBinder(JNIEnv* env, AIBinder* binder); __END_DECLS /** @} */
libs/binder/ndk/libbinder_ndk.map.txt +2 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ LIBBINDER_NDK { # introduced=29 AIBinder_DeathRecipient_new; AIBinder_debugGetRefCount; AIBinder_decStrong; AIBinder_fromJavaBinder; AIBinder_getClass; AIBinder_getUserData; AIBinder_incStrong; Loading @@ -15,6 +16,7 @@ LIBBINDER_NDK { # introduced=29 AIBinder_new; AIBinder_ping; AIBinder_prepareTransaction; AIBinder_toJavaBinder; AIBinder_transact; AIBinder_unlinkToDeath; AIBinder_Weak_delete; Loading
libs/binder/ndk/scripts/init_map.sh +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ echo "LIBBINDER_NDK { # introduced=29" echo " global:" { grep -oP "AIBinder_[a-zA-Z0-9_]+(?=\()" include_ndk/android/binder_ibinder.h; grep -oP "AIBinder_[a-zA-Z0-9_]+(?=\()" include_ndk/android/binder_ibinder_jni.h; grep -oP "AParcel_[a-zA-Z0-9_]+(?=\()" include_ndk/android/binder_parcel.h; grep -oP "AStatus_[a-zA-Z0-9_]+(?=\()" include_ndk/android/binder_status.h; } | sort | uniq | awk '{ print " " $0 ";"; }' Loading