libhidltransport: move methods to sources
Moved all methods with no templatization into sources.
Test: links
Bug: 35710429
Change-Id: I44bd6407e1bd74dd188b4033ddf176587ccdd8e7
diff --git a/transport/Android.bp b/transport/Android.bp
index 47a4de3..4e424be 100644
--- a/transport/Android.bp
+++ b/transport/Android.bp
@@ -59,6 +59,7 @@
srcs: [
"HidlBinderSupport.cpp",
"HidlTransportSupport.cpp",
+ "HidlTransportUtils.cpp",
"ServiceManagement.cpp",
"Static.cpp"
],
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index f421953..7788e33 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -28,6 +28,22 @@
namespace android {
namespace hardware {
+hidl_binder_death_recipient::hidl_binder_death_recipient(const sp<hidl_death_recipient> &recipient,
+ uint64_t cookie, const sp<::android::hidl::base::V1_0::IBase> &base) :
+ mRecipient(recipient), mCookie(cookie), mBase(base) {
+}
+
+void hidl_binder_death_recipient::binderDied(const wp<IBinder>& /*who*/) {
+ sp<hidl_death_recipient> recipient = mRecipient.promote();
+ if (recipient != nullptr) {
+ recipient->serviceDied(mCookie, mBase);
+ }
+}
+
+wp<hidl_death_recipient> hidl_binder_death_recipient::getRecipient() {
+ return mRecipient;
+}
+
const size_t hidl_memory::kOffsetOfHandle = offsetof(hidl_memory, mHandle);
const size_t hidl_memory::kOffsetOfName = offsetof(hidl_memory, mName);
static_assert(hidl_memory::kOffsetOfHandle == 0, "wrong offset");
diff --git a/transport/HidlTransportUtils.cpp b/transport/HidlTransportUtils.cpp
new file mode 100644
index 0000000..eda9b8a
--- /dev/null
+++ b/transport/HidlTransportUtils.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2016 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 <hidl/HidlTransportUtils.h>
+
+namespace android {
+namespace hardware {
+namespace details {
+
+Return<bool> canCastInterface(::android::hidl::base::V1_0::IBase* interface,
+ const char* castTo, bool emitError) {
+ if (interface == nullptr) {
+ return false;
+ }
+
+ bool canCast = false;
+ auto chainRet = interface->interfaceChain([&](const hidl_vec<hidl_string> &types) {
+ for (size_t i = 0; i < types.size(); i++) {
+ if (types[i] == castTo) {
+ canCast = true;
+ break;
+ }
+ }
+ });
+
+ if (!chainRet.isOk()) {
+ // call fails, propagate the error if emitError
+ return emitError
+ ? details::StatusOf<void, bool>(chainRet)
+ : Return<bool>(false);
+ }
+
+ return canCast;
+}
+
+std::string getDescriptor(::android::hidl::base::V1_0::IBase* interface) {
+ std::string myDescriptor{};
+ auto ret = interface->interfaceDescriptor([&](const hidl_string &types) {
+ myDescriptor = types.c_str();
+ });
+ ret.isOk(); // ignored, return empty string if not isOk()
+ return myDescriptor;
+}
+
+} // namespace details
+} // namespace hardware
+} // namespace android
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index a82f977..6f82dbc 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -40,18 +40,9 @@
// DeathRecipient interface.
struct hidl_binder_death_recipient : IBinder::DeathRecipient {
hidl_binder_death_recipient(const sp<hidl_death_recipient> &recipient,
- uint64_t cookie, const sp<::android::hidl::base::V1_0::IBase> &base) :
- mRecipient(recipient), mCookie(cookie), mBase(base) {
- }
- virtual void binderDied(const wp<IBinder>& /*who*/) {
- sp<hidl_death_recipient> recipient = mRecipient.promote();
- if (recipient != nullptr) {
- recipient->serviceDied(mCookie, mBase);
- }
- }
- wp<hidl_death_recipient> getRecipient() {
- return mRecipient;
- }
+ uint64_t cookie, const sp<::android::hidl::base::V1_0::IBase> &base);
+ virtual void binderDied(const wp<IBinder>& /*who*/);
+ wp<hidl_death_recipient> getRecipient();
private:
wp<hidl_death_recipient> mRecipient;
uint64_t mCookie;
diff --git a/transport/include/hidl/HidlTransportUtils.h b/transport/include/hidl/HidlTransportUtils.h
index fbd6516..5afb9a6 100644
--- a/transport/include/hidl/HidlTransportUtils.h
+++ b/transport/include/hidl/HidlTransportUtils.h
@@ -28,40 +28,10 @@
* @param emitError if emitError is false, return Return<bool>{false} on error; if emitError
* is true, the Return<bool> object contains the actual error.
*/
-inline Return<bool> canCastInterface(::android::hidl::base::V1_0::IBase* interface,
- const char* castTo, bool emitError = false) {
- if (interface == nullptr) {
- return false;
- }
+Return<bool> canCastInterface(::android::hidl::base::V1_0::IBase* interface,
+ const char* castTo, bool emitError = false);
- bool canCast = false;
- auto chainRet = interface->interfaceChain([&](const hidl_vec<hidl_string> &types) {
- for (size_t i = 0; i < types.size(); i++) {
- if (types[i] == castTo) {
- canCast = true;
- break;
- }
- }
- });
-
- if (!chainRet.isOk()) {
- // call fails, propagate the error if emitError
- return emitError
- ? details::StatusOf<void, bool>(chainRet)
- : Return<bool>(false);
- }
-
- return canCast;
-}
-
-inline std::string getDescriptor(::android::hidl::base::V1_0::IBase* interface) {
- std::string myDescriptor{};
- auto ret = interface->interfaceDescriptor([&](const hidl_string &types) {
- myDescriptor = types.c_str();
- });
- ret.isOk(); // ignored, return empty string if not isOk()
- return myDescriptor;
-}
+std::string getDescriptor(::android::hidl::base::V1_0::IBase* interface);
} // namespace details
} // namespace hardware