Merge "Add unsynchronized write flavor to MQDescriptor"
diff --git a/IServiceManager.cpp b/IServiceManager.cpp
index df44d3b..9a19554 100644
--- a/IServiceManager.cpp
+++ b/IServiceManager.cpp
@@ -23,7 +23,6 @@
#include <utils/Log.h>
#include <hwbinder/IPCThreadState.h>
#include <hwbinder/Parcel.h>
-#include <hwbinder/Static.h>
#include <utils/String8.h>
#include <utils/SystemClock.h>
diff --git a/include/hidl/HidlSupport.h b/include/hidl/HidlSupport.h
index f9f7f14..3b539bc 100644
--- a/include/hidl/HidlSupport.h
+++ b/include/hidl/HidlSupport.h
@@ -82,6 +82,10 @@
*this = other;
}
+ hidl_vec(hidl_vec<T> &&other) {
+ *this = static_cast<hidl_vec &&>(other);
+ }
+
~hidl_vec() {
if (mOwnsBuffer) {
delete[] mBuffer;
@@ -89,16 +93,40 @@
mBuffer = NULL;
}
- // Reference an existing array _WITHOUT_ taking ownership. It is the
+ // Reference an existing array, optionally taking ownership. It is the
// caller's responsibility to ensure that the underlying memory stays
// valid for the lifetime of this hidl_vec.
- void setToExternal(T *data, size_t size) {
+ void setToExternal(T *data, size_t size, bool shouldOwn = false) {
if (mOwnsBuffer) {
delete [] mBuffer;
}
mBuffer = data;
mSize = size;
+ mOwnsBuffer = shouldOwn;
+ }
+
+ T *data() {
+ return mBuffer;
+ }
+
+ const T *data() const {
+ return mBuffer;
+ }
+
+ T *releaseData() {
+ if (!mOwnsBuffer && mSize > 0) {
+ resize(mSize);
+ }
mOwnsBuffer = false;
+ return mBuffer;
+ }
+
+ hidl_vec &operator=(hidl_vec &&other) {
+ mBuffer = other.mBuffer;
+ mSize = other.mSize;
+ mOwnsBuffer = other.mOwnsBuffer;
+ other.mOwnsBuffer = false;
+ return *this;
}
hidl_vec &operator=(const hidl_vec &other) {
diff --git a/include/hidl/LegacySupport.h b/include/hidl/LegacySupport.h
new file mode 100644
index 0000000..5acc1d0
--- /dev/null
+++ b/include/hidl/LegacySupport.h
@@ -0,0 +1,65 @@
+/*
+ * 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 <utils/Log.h>
+
+#include "IServiceManager.h"
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <utils/Errors.h>
+#include <utils/StrongPointer.h>
+
+#ifndef ANDROID_HIDL_LEGACY_SUPPORT_H
+#define ANDROID_HIDL_LEGACY_SUPPORT_H
+
+namespace android {
+namespace hardware {
+
+/**
+ * Creates default passthrough service implementation. This method never returns.
+ *
+ * Return value is exit status.
+ */
+template<class Interface>
+int defaultPassthroughServiceImplementation(std::string name) {
+ sp<Interface> service = Interface::getService(name, true /* getStub */);
+
+ if (service == nullptr) {
+ ALOGE("Could not get passthrough implementation.");
+ return EXIT_FAILURE;
+ }
+
+ LOG_FATAL_IF(service->isRemote(), "Implementation is remote!");
+
+ status_t status = service->registerAsService(name);
+
+ if (status == OK) {
+ ALOGI("Registration complete.");
+ } else {
+ ALOGE("Could not register service (%d).", status);
+ }
+
+ ProcessState::self()->setThreadPoolMaxThreadCount(0);
+ ProcessState::self()->startThreadPool();
+ IPCThreadState::self()->joinThreadPool();
+
+ return 0;
+}
+
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HIDL_LEGACY_SUPPORT_H
\ No newline at end of file