canCastInterface: always return true for IBase am: 3fa8e305eb -s ours
am: c42da043b6 -s ours
Change-Id: I5e846272e8a478304314f6917017cc7ca85cb4f3
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 7d4e281..f3573c5 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -46,3 +46,6 @@
$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/bin/hw/android.hidl.memory@1.0-service)
$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/etc/init/android.hidl.memory@1.0-service.rc)
+
+# memory@1.0-impl is moved to /system/lib/vndk-sp
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib/hw/android.hidl.memory@1.0-impl.so)
diff --git a/base/Android.bp b/base/Android.bp
index e4cf6cb..5a38ed8 100644
--- a/base/Android.bp
+++ b/base/Android.bp
@@ -15,6 +15,10 @@
cc_library_shared {
name: "libhidlbase",
vendor_available: true,
+ vndk: {
+ enabled: true,
+ support_system_process: true,
+ },
cflags: libhidl_flags,
shared_libs: [
"libbase",
diff --git a/base/HidlInternal.cpp b/base/HidlInternal.cpp
index b0d867f..c534a4c 100644
--- a/base/HidlInternal.cpp
+++ b/base/HidlInternal.cpp
@@ -77,6 +77,7 @@
instrumentationLibPaths.push_back(instrumentationLibPath);
} else {
instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_SYSTEM);
+ instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_VNDK_SP);
instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_VENDOR);
instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_ODM);
}
diff --git a/base/include/hidl/HidlInternal.h b/base/include/hidl/HidlInternal.h
index 6c0d8df..7a24cd5 100644
--- a/base/include/hidl/HidlInternal.h
+++ b/base/include/hidl/HidlInternal.h
@@ -44,15 +44,9 @@
hidl_pointer()
: _pad(0) {
}
- hidl_pointer(T* ptr)
- : mPointer(ptr) {
- }
- hidl_pointer(const hidl_pointer<T>& other) {
- mPointer = other.mPointer;
- }
- hidl_pointer(hidl_pointer<T>&& other) {
- *this = std::move(other);
- }
+ hidl_pointer(T* ptr) : hidl_pointer() { mPointer = ptr; }
+ hidl_pointer(const hidl_pointer<T>& other) : hidl_pointer() { mPointer = other.mPointer; }
+ hidl_pointer(hidl_pointer<T>&& other) : hidl_pointer() { *this = std::move(other); }
hidl_pointer &operator=(const hidl_pointer<T>& other) {
mPointer = other.mPointer;
@@ -95,18 +89,22 @@
};
#define HAL_LIBRARY_PATH_SYSTEM_64BIT "/system/lib64/hw/"
+#define HAL_LIBRARY_PATH_VNDK_SP_64BIT "/system/lib64/vndk-sp/hw/"
#define HAL_LIBRARY_PATH_VENDOR_64BIT "/vendor/lib64/hw/"
#define HAL_LIBRARY_PATH_ODM_64BIT "/odm/lib64/hw/"
#define HAL_LIBRARY_PATH_SYSTEM_32BIT "/system/lib/hw/"
+#define HAL_LIBRARY_PATH_VNDK_SP_32BIT "/system/lib/vndk-sp/hw/"
#define HAL_LIBRARY_PATH_VENDOR_32BIT "/vendor/lib/hw/"
#define HAL_LIBRARY_PATH_ODM_32BIT "/odm/lib/hw/"
#if defined(__LP64__)
#define HAL_LIBRARY_PATH_SYSTEM HAL_LIBRARY_PATH_SYSTEM_64BIT
+#define HAL_LIBRARY_PATH_VNDK_SP HAL_LIBRARY_PATH_VNDK_SP_64BIT
#define HAL_LIBRARY_PATH_VENDOR HAL_LIBRARY_PATH_VENDOR_64BIT
#define HAL_LIBRARY_PATH_ODM HAL_LIBRARY_PATH_ODM_64BIT
#else
#define HAL_LIBRARY_PATH_SYSTEM HAL_LIBRARY_PATH_SYSTEM_32BIT
+#define HAL_LIBRARY_PATH_VNDK_SP HAL_LIBRARY_PATH_VNDK_SP_32BIT
#define HAL_LIBRARY_PATH_VENDOR HAL_LIBRARY_PATH_VENDOR_32BIT
#define HAL_LIBRARY_PATH_ODM HAL_LIBRARY_PATH_ODM_32BIT
#endif
@@ -144,7 +142,13 @@
const std::string &insterface);
virtual ~HidlInstrumentor();
- protected:
+ public:
+ const std::vector<InstrumentationCallback>& getInstrumentationCallbacks() {
+ return mInstrumentationCallbacks;
+ }
+ bool isInstrumentationEnabled() { return mEnableInstrumentation; }
+
+ protected:
// Set mEnableInstrumentation based on system property
// hal.instrumentation.enable, register/de-register instrumentation
// callbacks if mEnableInstrumentation is true/false.
@@ -153,9 +157,10 @@
// libraries and registers the instrumentation callback functions.
//
// The instrumentation libraries should be stored under any of the following
- // directories: HAL_LIBRARY_PATH_SYSTEM, HAL_LIBRARY_PATH_VENDOR and
- // HAL_LIBRARY_PATH_ODM. The name of instrumentation libraries should
- // follow pattern: ^profilerPrefix(.*).profiler.so$
+ // directories: HAL_LIBRARY_PATH_SYSTEM, HAL_LIBRARY_PATH_VNDK_SP,
+ // HAL_LIBRARY_PATH_VENDOR and HAL_LIBRARY_PATH_ODM.
+ // The name of instrumentation libraries should follow pattern:
+ // ^profilerPrefix(.*).profiler.so$
//
// Each instrumentation library is expected to implement the instrumentation
// function called HIDL_INSTRUMENTATION_FUNCTION.
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 6807860..f25cdc4 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -316,6 +316,27 @@
*this = other;
}
+ template <typename InputIterator,
+ typename = typename std::enable_if<std::is_convertible<
+ typename std::iterator_traits<InputIterator>::iterator_category,
+ std::input_iterator_tag>::value>::type>
+ hidl_vec(InputIterator first, InputIterator last) : mOwnsBuffer(true) {
+ auto size = std::distance(first, last);
+ if (size > static_cast<int64_t>(UINT32_MAX)) {
+ details::logAlwaysFatal("hidl_vec can't hold more than 2^32 elements.");
+ }
+ if (size < 0) {
+ details::logAlwaysFatal("size can't be negative.");
+ }
+ mSize = static_cast<uint32_t>(size);
+ mBuffer = new T[mSize];
+
+ size_t idx = 0;
+ for (; first != last; ++first) {
+ mBuffer[idx++] = static_cast<T>(*first);
+ }
+ }
+
~hidl_vec() {
if (mOwnsBuffer) {
delete[] mBuffer;
diff --git a/base/include/hidl/Status.h b/base/include/hidl/Status.h
index 7c716c7..f812ebb 100644
--- a/base/include/hidl/Status.h
+++ b/base/include/hidl/Status.h
@@ -161,9 +161,17 @@
}
// Check if underlying error is DEAD_OBJECT.
- // Does not set mCheckedStatus.
+ // Check mCheckedStatus only if this method returns true.
bool isDeadObject() const {
- return mStatus.transactionError() == DEAD_OBJECT;
+ bool dead = mStatus.transactionError() == DEAD_OBJECT;
+
+ // This way, if you only check isDeadObject your process will
+ // only be killed for more serious unchecked errors
+ if (dead) {
+ mCheckedStatus = true;
+ }
+
+ return dead;
}
// For debugging purposes only
diff --git a/libhidlmemory/Android.bp b/libhidlmemory/Android.bp
index 79ec4bc..59ce7a8 100644
--- a/libhidlmemory/Android.bp
+++ b/libhidlmemory/Android.bp
@@ -12,9 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-cc_library_shared {
+cc_library {
name: "libhidlmemory",
vendor_available: true,
+ vndk: {
+ enabled: true,
+ support_system_process: true,
+ },
cflags: libhidl_flags,
shared_libs: [
"libbase",
diff --git a/manifest.xml b/manifest.xml
index eb64dab..f34bfb1 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -2,7 +2,7 @@
<hal>
<name>android.hidl.manager</name>
<transport>hwbinder</transport>
- <version>1.0</version>
+ <version>1.1</version>
<interface>
<name>IServiceManager</name>
<instance>default</instance>
@@ -89,4 +89,18 @@
<instance>vr</instance>
</interface>
</hal>
+ <hal format="native">
+ <name>netutils-wrapper</name>
+ <!--
+ netutils-wrapper versions must be x.0.
+ netutils-wrapper next version has less functionalities than
+ previous versions, so unlike a HAL, netutils-wrapper are not
+ backwards compatible. Hence the major version must be bumped for
+ each update.
+ If a minor version were bumped instead (say, <version>1.1</version>),
+ it would be incorrectly considered compatible with version 1.0 in
+ device compatibility matrix.
+ -->
+ <version>1.0</version>
+ </hal>
</manifest>
diff --git a/test_main.cpp b/test_main.cpp
index bce9294..1f2f845 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -262,6 +262,30 @@
EXPECT_TRUE(hv1 != hv3);
}
+TEST_F(LibHidlTest, VecRangeCtorTest) {
+ struct ConvertibleType {
+ int val;
+
+ explicit ConvertibleType(int val) : val(val) {}
+ explicit operator int() const { return val; }
+ bool operator==(const int& other) const { return val == other; }
+ };
+
+ std::vector<ConvertibleType> input{
+ ConvertibleType(1), ConvertibleType(2), ConvertibleType(3),
+ };
+
+ android::hardware::hidl_vec<int> hv(input.begin(), input.end());
+
+ EXPECT_EQ(input.size(), hv.size());
+ int sum = 0;
+ for (unsigned i = 0; i < input.size(); i++) {
+ EXPECT_EQ(input[i], hv[i]);
+ sum += hv[i];
+ }
+ EXPECT_EQ(sum, 1 + 2 + 3);
+}
+
TEST_F(LibHidlTest, ArrayTest) {
using android::hardware::hidl_array;
int32_t array[] = {5, 6, 7};
diff --git a/transport/Android.bp b/transport/Android.bp
index 73eee3a..cf499ef 100644
--- a/transport/Android.bp
+++ b/transport/Android.bp
@@ -17,6 +17,7 @@
"allocator/1.0/default",
"base/1.0",
"manager/1.0",
+ "manager/1.1",
"memory/1.0",
"memory/1.0/default",
"token/1.0",
@@ -26,6 +27,10 @@
cc_library_shared {
name: "libhidltransport",
vendor_available: true,
+ vndk: {
+ enabled: true,
+ support_system_process: true,
+ },
defaults: ["hidl-module-defaults"],
cflags: libhidl_flags,
shared_libs: [
@@ -47,14 +52,17 @@
generated_sources: [
"android.hidl.manager@1.0_genc++",
+ "android.hidl.manager@1.1_genc++",
"android.hidl.base@1.0_genc++"
],
generated_headers: [
"android.hidl.manager@1.0_genc++_headers",
+ "android.hidl.manager@1.1_genc++_headers",
"android.hidl.base@1.0_genc++_headers"
],
export_generated_headers: [
"android.hidl.manager@1.0_genc++_headers",
+ "android.hidl.manager@1.1_genc++_headers",
"android.hidl.base@1.0_genc++_headers"
],
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index 5e2d1a5..72ac53a 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -38,9 +38,9 @@
#include <hwbinder/Parcel.h>
#include <vndksupport/linker.h>
-#include <android/hidl/manager/1.0/IServiceManager.h>
-#include <android/hidl/manager/1.0/BpHwServiceManager.h>
-#include <android/hidl/manager/1.0/BnHwServiceManager.h>
+#include <android/hidl/manager/1.1/IServiceManager.h>
+#include <android/hidl/manager/1.1/BpHwServiceManager.h>
+#include <android/hidl/manager/1.1/BnHwServiceManager.h>
#define RE_COMPONENT "[a-zA-Z_][a-zA-Z_0-9]*"
#define RE_PATH RE_COMPONENT "(?:[.]" RE_COMPONENT ")*"
@@ -48,17 +48,18 @@
using android::base::WaitForProperty;
-using android::hidl::manager::V1_0::IServiceManager;
+using IServiceManager1_0 = android::hidl::manager::V1_0::IServiceManager;
+using IServiceManager1_1 = android::hidl::manager::V1_1::IServiceManager;
using android::hidl::manager::V1_0::IServiceNotification;
-using android::hidl::manager::V1_0::BpHwServiceManager;
-using android::hidl::manager::V1_0::BnHwServiceManager;
+using android::hidl::manager::V1_1::BpHwServiceManager;
+using android::hidl::manager::V1_1::BnHwServiceManager;
namespace android {
namespace hardware {
namespace details {
extern Mutex gDefaultServiceManagerLock;
-extern sp<android::hidl::manager::V1_0::IServiceManager> gDefaultServiceManager;
+extern sp<android::hidl::manager::V1_1::IServiceManager> gDefaultServiceManager;
} // namespace details
static const char* kHwServicemanagerReadyProperty = "hwservicemanager.ready";
@@ -132,7 +133,10 @@
} // details
-sp<IServiceManager> defaultServiceManager() {
+sp<IServiceManager1_0> defaultServiceManager() {
+ return defaultServiceManager1_1();
+}
+sp<IServiceManager1_1> defaultServiceManager1_1() {
{
AutoMutex _l(details::gDefaultServiceManagerLock);
if (details::gDefaultServiceManager != NULL) {
@@ -149,7 +153,7 @@
while (details::gDefaultServiceManager == NULL) {
details::gDefaultServiceManager =
- fromBinder<IServiceManager, BpHwServiceManager, BnHwServiceManager>(
+ fromBinder<IServiceManager1_1, BpHwServiceManager, BnHwServiceManager>(
ProcessState::self()->getContextObject(NULL));
if (details::gDefaultServiceManager == NULL) {
LOG(ERROR) << "Waited for hwservicemanager, but got nullptr.";
@@ -193,7 +197,7 @@
}
static void registerReference(const hidl_string &interfaceName, const hidl_string &instanceName) {
- sp<IServiceManager> binderizedManager = defaultServiceManager();
+ sp<IServiceManager1_0> binderizedManager = defaultServiceManager();
if (binderizedManager == nullptr) {
LOG(WARNING) << "Could not registerReference for "
<< interfaceName << "/" << instanceName
@@ -249,7 +253,7 @@
}
}
-struct PassthroughServiceManager : IServiceManager {
+struct PassthroughServiceManager : IServiceManager1_1 {
static void openLibs(const std::string& fqName,
std::function<bool /* continue */(void* /* handle */,
const std::string& /* lib */, const std::string& /* sym */)> eachLib) {
@@ -274,7 +278,7 @@
dlerror(); // clear
std::vector<std::string> paths = {HAL_LIBRARY_PATH_ODM, HAL_LIBRARY_PATH_VENDOR,
- HAL_LIBRARY_PATH_SYSTEM};
+ HAL_LIBRARY_PATH_VNDK_SP, HAL_LIBRARY_PATH_SYSTEM};
#ifdef LIBHIDL_TARGET_DEBUGGABLE
const char* env = std::getenv("TREBLE_TESTING_OVERRIDE");
const bool trebleTestingOverride = env && !strcmp(env, "true");
@@ -377,14 +381,13 @@
Return<void> debugDump(debugDump_cb _hidl_cb) override {
using Arch = ::android::hidl::base::V1_0::DebugInfo::Architecture;
using std::literals::string_literals::operator""s;
- static std::vector<std::pair<Arch, std::vector<const char *>>> sAllPaths{
- {Arch::IS_64BIT, {HAL_LIBRARY_PATH_ODM_64BIT,
- HAL_LIBRARY_PATH_VENDOR_64BIT,
- HAL_LIBRARY_PATH_SYSTEM_64BIT}},
- {Arch::IS_32BIT, {HAL_LIBRARY_PATH_ODM_32BIT,
- HAL_LIBRARY_PATH_VENDOR_32BIT,
- HAL_LIBRARY_PATH_SYSTEM_32BIT}}
- };
+ static std::vector<std::pair<Arch, std::vector<const char*>>> sAllPaths{
+ {Arch::IS_64BIT,
+ {HAL_LIBRARY_PATH_ODM_64BIT, HAL_LIBRARY_PATH_VENDOR_64BIT,
+ HAL_LIBRARY_PATH_VNDK_SP_64BIT, HAL_LIBRARY_PATH_SYSTEM_64BIT}},
+ {Arch::IS_32BIT,
+ {HAL_LIBRARY_PATH_ODM_32BIT, HAL_LIBRARY_PATH_VENDOR_32BIT,
+ HAL_LIBRARY_PATH_VNDK_SP_32BIT, HAL_LIBRARY_PATH_SYSTEM_32BIT}}};
std::map<std::string, InstanceDebugInfo> map;
for (const auto &pair : sAllPaths) {
Arch arch = pair.first;
@@ -422,9 +425,20 @@
return Void();
}
+ Return<bool> unregisterForNotifications(const hidl_string& /* fqName */,
+ const hidl_string& /* name */,
+ const sp<IServiceNotification>& /* callback */) override {
+ // This makes no sense.
+ LOG(FATAL) << "Cannot unregister for notifications with passthrough service manager.";
+ return false;
+ }
+
};
-sp<IServiceManager> getPassthroughServiceManager() {
+sp<IServiceManager1_0> getPassthroughServiceManager() {
+ return getPassthroughServiceManager1_1();
+}
+sp<IServiceManager1_1> getPassthroughServiceManager1_1() {
static sp<PassthroughServiceManager> manager(new PassthroughServiceManager());
return manager;
}
@@ -481,7 +495,7 @@
void waitForHwService(
const std::string &interface, const std::string &instanceName) {
- const sp<IServiceManager> manager = defaultServiceManager();
+ const sp<IServiceManager1_1> manager = defaultServiceManager1_1();
if (manager == nullptr) {
LOG(ERROR) << "Could not get default service manager.";
@@ -505,6 +519,11 @@
}
waiter->wait(interface, instanceName);
+
+ if (!manager->unregisterForNotifications(interface, instanceName, waiter).withDefault(false)) {
+ LOG(ERROR) << "Could not unregister service notification for "
+ << interface << "/" << instanceName << ".";
+ }
}
}; // namespace details
diff --git a/transport/Static.cpp b/transport/Static.cpp
index 18cb475..784b835 100644
--- a/transport/Static.cpp
+++ b/transport/Static.cpp
@@ -32,6 +32,9 @@
ConcurrentMap<std::string, std::function<sp<IBinder>(void *)>>
gBnConstructorMap{};
+ConcurrentMap<const ::android::hidl::base::V1_0::IBase*, wp<::android::hardware::BHwBinder>>
+ gBnMap{};
+
ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio> gServicePrioMap{};
ConcurrentMap<std::string, std::function<sp<::android::hidl::base::V1_0::IBase>(void *)>>
diff --git a/transport/allocator/1.0/Android.bp b/transport/allocator/1.0/Android.bp
index b836d26..c64a039 100644
--- a/transport/allocator/1.0/Android.bp
+++ b/transport/allocator/1.0/Android.bp
@@ -35,13 +35,16 @@
],
}
-cc_library_shared {
+cc_library {
name: "android.hidl.allocator@1.0",
defaults: ["hidl-module-defaults"],
generated_sources: ["android.hidl.allocator@1.0_genc++"],
generated_headers: ["android.hidl.allocator@1.0_genc++_headers"],
export_generated_headers: ["android.hidl.allocator@1.0_genc++_headers"],
vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/transport/current.txt b/transport/current.txt
index a6ecd81..958d679 100644
--- a/transport/current.txt
+++ b/transport/current.txt
@@ -11,3 +11,7 @@
2b885b5dec97391c82f35e64180686dc4c8f78b2b0a01732f8536385654f27c8 android.hidl.memory@1.0::IMapper
4632246017013e75536fa6ee47db286b24a323fb92c37c6b14bb0ab796b7a16b android.hidl.memory@1.0::IMemory
7c9fe352af04af659bd51ab6f5495115575bc063ddf684fc6d0dec1f4a4b4b7c android.hidl.token@1.0::ITokenManager
+
+# HALs released in Android O-MR1
+
+0b94dc876f749ed24a98f61c41d46ad75a27511163f1968a084213a33c684ef6 android.hidl.manager@1.1::IServiceManager
diff --git a/transport/include/hidl/ConcurrentMap.h b/transport/include/hidl/ConcurrentMap.h
index 18881f1..4066869 100644
--- a/transport/include/hidl/ConcurrentMap.h
+++ b/transport/include/hidl/ConcurrentMap.h
@@ -50,7 +50,33 @@
return mMap.erase(k);
}
-private:
+ size_type eraseIfEqual(const K& k, const V& v) {
+ std::unique_lock<std::mutex> _lock(mMutex);
+ const_iterator iter = mMap.find(k);
+ if (iter == mMap.end()) {
+ return 0;
+ }
+ if (iter->second == v) {
+ mMap.erase(iter);
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ std::unique_lock<std::mutex> lock() { return std::unique_lock<std::mutex>(mMutex); }
+
+ void setLocked(K&& k, V&& v) { mMap[std::forward<K>(k)] = std::forward<V>(v); }
+
+ const V& getLocked(const K& k, const V& def) const {
+ const_iterator iter = mMap.find(k);
+ if (iter == mMap.end()) {
+ return def;
+ }
+ return iter->second;
+ }
+
+ private:
mutable std::mutex mMutex;
std::map<K, V> mMap;
};
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 6f82dbc..47ff581 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -306,25 +306,42 @@
// Otherwise, the smallest possible BnChild is found where IChild is a subclass of IType
// and iface is of class IChild. BnChild will be used to wrapped the given iface.
// Return nullptr if iface is null or any failure.
-template <typename IType, typename ProxyType>
+template <typename IType>
sp<IBinder> toBinder(sp<IType> iface) {
IType *ifacePtr = iface.get();
if (ifacePtr == nullptr) {
return nullptr;
}
if (ifacePtr->isRemote()) {
- return ::android::hardware::IInterface::asBinder(static_cast<ProxyType *>(ifacePtr));
+ return ::android::hardware::IInterface::asBinder(
+ static_cast<BpInterface<IType>*>(ifacePtr));
} else {
std::string myDescriptor = details::getDescriptor(ifacePtr);
if (myDescriptor.empty()) {
// interfaceDescriptor fails
return nullptr;
}
- auto func = details::gBnConstructorMap.get(myDescriptor, nullptr);
- if (!func) {
- return nullptr;
+
+ // for get + set
+ std::unique_lock<std::mutex> _lock = details::gBnMap.lock();
+
+ wp<BHwBinder> wBnObj = details::gBnMap.getLocked(ifacePtr, nullptr);
+ sp<IBinder> sBnObj = wBnObj.promote();
+
+ if (sBnObj == nullptr) {
+ auto func = details::gBnConstructorMap.get(myDescriptor, nullptr);
+ if (!func) {
+ return nullptr;
+ }
+
+ sBnObj = sp<IBinder>(func(static_cast<void*>(ifacePtr)));
+
+ if (sBnObj != nullptr) {
+ details::gBnMap.setLocked(ifacePtr, static_cast<BHwBinder*>(sBnObj.get()));
+ }
}
- return sp<IBinder>(func(static_cast<void *>(ifacePtr)));
+
+ return sBnObj;
}
}
diff --git a/transport/include/hidl/HidlTransportSupport.h b/transport/include/hidl/HidlTransportSupport.h
index 0c174f7..d116598 100644
--- a/transport/include/hidl/HidlTransportSupport.h
+++ b/transport/include/hidl/HidlTransportSupport.h
@@ -62,6 +62,15 @@
bool setMinSchedulerPolicy(const sp<::android::hidl::base::V1_0::IBase>& service,
int policy, int priority);
+template <typename ILeft, typename IRight>
+bool interfacesEqual(sp<ILeft> left, sp<IRight> right) {
+ if (left == nullptr || right == nullptr || !left->isRemote() || !right->isRemote()) {
+ return left == right;
+ }
+
+ return toBinder<ILeft>(left) == toBinder<IRight>(right);
+}
+
namespace details {
// cast the interface IParent to IChild.
@@ -72,8 +81,8 @@
// 3. !emitError, calling into parent fails.
// Return an error Return object if:
// 1. emitError, calling into parent fails.
-template<typename IChild, typename IParent, typename BpChild, typename BpParent>
-Return<sp<IChild>> castInterface(sp<IParent> parent, const char *childIndicator, bool emitError) {
+template <typename IChild, typename IParent, typename BpChild>
+Return<sp<IChild>> castInterface(sp<IParent> parent, const char* childIndicator, bool emitError) {
if (parent.get() == nullptr) {
// casts always succeed with nullptrs.
return nullptr;
@@ -92,7 +101,7 @@
// TODO b/32001926 Needs to be fixed for socket mode.
if (parent->isRemote()) {
// binderized mode. Got BpChild. grab the remote and wrap it.
- return sp<IChild>(new BpChild(toBinder<IParent, BpParent>(parent)));
+ return sp<IChild>(new BpChild(toBinder<IParent>(parent)));
}
// Passthrough mode. Got BnChild and BsChild.
return sp<IChild>(static_cast<IChild *>(parent.get()));
diff --git a/transport/include/hidl/ServiceManagement.h b/transport/include/hidl/ServiceManagement.h
index 324a584..d53cd7e 100644
--- a/transport/include/hidl/ServiceManagement.h
+++ b/transport/include/hidl/ServiceManagement.h
@@ -27,6 +27,9 @@
namespace V1_0 {
struct IServiceManager;
}; // namespace V1_0
+namespace V1_1 {
+ struct IServiceManager;
+}; // namespace V1_0
}; // namespace manager
}; // namespace hidl
@@ -47,7 +50,9 @@
// These functions are for internal use by hidl. If you want to get ahold
// of an interface, the best way to do this is by calling IFoo::getService()
sp<::android::hidl::manager::V1_0::IServiceManager> defaultServiceManager();
+sp<::android::hidl::manager::V1_1::IServiceManager> defaultServiceManager1_1();
sp<::android::hidl::manager::V1_0::IServiceManager> getPassthroughServiceManager();
+sp<::android::hidl::manager::V1_1::IServiceManager> getPassthroughServiceManager1_1();
/**
* Given a service that is in passthrough mode, this function will go ahead and load the
diff --git a/transport/include/hidl/Static.h b/transport/include/hidl/Static.h
index 0133ff7..63b06fe 100644
--- a/transport/include/hidl/Static.h
+++ b/transport/include/hidl/Static.h
@@ -22,6 +22,7 @@
#include <android/hidl/base/1.0/IBase.h>
#include <hidl/ConcurrentMap.h>
#include <hwbinder/IBinder.h>
+#include <hwbinder/IInterface.h>
#include <utils/StrongPointer.h>
namespace android {
@@ -33,14 +34,18 @@
int prio;
};
+extern ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio> gServicePrioMap;
+
+// For HidlBinderSupport and autogenerated code
+extern ConcurrentMap<const ::android::hidl::base::V1_0::IBase*, wp<::android::hardware::BHwBinder>>
+ gBnMap;
+
// For HidlBinderSupport and autogenerated code
// value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)),
// returns sp<IBinder>
extern ConcurrentMap<std::string,
std::function<sp<IBinder>(void *)>> gBnConstructorMap;
-extern ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio> gServicePrioMap;
-
// For HidlPassthroughSupport and autogenerated code
// value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)),
// returns sp<IBase>
diff --git a/transport/manager/1.1/Android.bp b/transport/manager/1.1/Android.bp
new file mode 100644
index 0000000..5a1bf00
--- /dev/null
+++ b/transport/manager/1.1/Android.bp
@@ -0,0 +1,38 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hidl.manager@1.1_hal",
+ srcs: [
+ "IServiceManager.hal",
+ ],
+}
+
+genrule {
+ name: "android.hidl.manager@1.1_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hidl:system/libhidl/transport android.hidl.manager@1.1",
+ srcs: [
+ ":android.hidl.manager@1.1_hal",
+ ],
+ out: [
+ "android/hidl/manager/1.1/ServiceManagerAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hidl.manager@1.1_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hidl:system/libhidl/transport android.hidl.manager@1.1",
+ srcs: [
+ ":android.hidl.manager@1.1_hal",
+ ],
+ out: [
+ "android/hidl/manager/1.1/IServiceManager.h",
+ "android/hidl/manager/1.1/IHwServiceManager.h",
+ "android/hidl/manager/1.1/BnHwServiceManager.h",
+ "android/hidl/manager/1.1/BpHwServiceManager.h",
+ "android/hidl/manager/1.1/BsServiceManager.h",
+ ],
+}
+
+// android.hidl.manager@1.1 is exported from libhidltransport
diff --git a/transport/manager/1.1/Android.mk b/transport/manager/1.1/Android.mk
new file mode 100644
index 0000000..20c9504
--- /dev/null
+++ b/transport/manager/1.1/Android.mk
@@ -0,0 +1,76 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hidl.manager-V1.1-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+ android.hidl.base-V1.0-java \
+ android.hidl.manager-V1.0-java \
+
+
+#
+# Build IServiceManager.hal
+#
+GEN := $(intermediates)/android/hidl/manager/V1_1/IServiceManager.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IServiceManager.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hidl:system/libhidl/transport \
+ android.hidl.manager@1.1::IServiceManager
+
+$(GEN): $(LOCAL_PATH)/IServiceManager.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hidl.manager-V1.1-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android.hidl.base-V1.0-java-static \
+ android.hidl.manager-V1.0-java-static \
+
+
+#
+# Build IServiceManager.hal
+#
+GEN := $(intermediates)/android/hidl/manager/V1_1/IServiceManager.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IServiceManager.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hidl:system/libhidl/transport \
+ android.hidl.manager@1.1::IServiceManager
+
+$(GEN): $(LOCAL_PATH)/IServiceManager.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/transport/manager/1.1/IServiceManager.hal b/transport/manager/1.1/IServiceManager.hal
new file mode 100644
index 0000000..cdc81cf
--- /dev/null
+++ b/transport/manager/1.1/IServiceManager.hal
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.hidl.manager@1.1;
+
+import @1.0::IServiceManager;
+import @1.0::IServiceNotification;
+
+interface IServiceManager extends @1.0::IServiceManager {
+
+ /**
+ * Unregister for service notifications for a specific callback.
+ *
+ * @param fqName Fully-qualified interface name. If empty, unregister for
+ * all notifications the callback receives.
+ * @param name Instance name. If name is empty, unregister for all instance
+ * names.
+ * @param callback Client callback that was previously registered.
+ *
+ * @return success Whether or not deregistration was successful.
+ */
+ unregisterForNotifications(string fqName,
+ string name,
+ IServiceNotification callback)
+ generates (bool success);
+
+};
diff --git a/transport/memory/1.0/Android.bp b/transport/memory/1.0/Android.bp
index ec9d0eb..b6044c2 100644
--- a/transport/memory/1.0/Android.bp
+++ b/transport/memory/1.0/Android.bp
@@ -42,13 +42,17 @@
],
}
-cc_library_shared {
+cc_library {
name: "android.hidl.memory@1.0",
defaults: ["hidl-module-defaults"],
generated_sources: ["android.hidl.memory@1.0_genc++"],
generated_headers: ["android.hidl.memory@1.0_genc++_headers"],
export_generated_headers: ["android.hidl.memory@1.0_genc++_headers"],
vendor_available: true,
+ vndk: {
+ enabled: true,
+ support_system_process: true,
+ },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/transport/memory/1.0/default/Android.bp b/transport/memory/1.0/default/Android.bp
index b0c601a..a4f45cf 100644
--- a/transport/memory/1.0/default/Android.bp
+++ b/transport/memory/1.0/default/Android.bp
@@ -14,6 +14,11 @@
cc_library_shared {
name: "android.hidl.memory@1.0-impl",
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ support_system_process: true,
+ },
compile_multilib: "both",
relative_install_path: "hw",
cflags: libhidl_flags,
@@ -23,12 +28,10 @@
"HidlFetch.cpp"
],
shared_libs: [
- "liblog",
"libcutils",
"libhardware",
"libhwbinder",
"libbase",
- "libcutils",
"libutils",
"libhidlbase",
"libhidltransport",
diff --git a/transport/token/1.0/Android.bp b/transport/token/1.0/Android.bp
index d5825c2..957d1f9 100644
--- a/transport/token/1.0/Android.bp
+++ b/transport/token/1.0/Android.bp
@@ -35,13 +35,16 @@
],
}
-cc_library_shared {
+cc_library {
name: "android.hidl.token@1.0",
defaults: ["hidl-module-defaults"],
generated_sources: ["android.hidl.token@1.0_genc++"],
generated_headers: ["android.hidl.token@1.0_genc++_headers"],
export_generated_headers: ["android.hidl.token@1.0_genc++_headers"],
vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/transport/token/1.0/utils/Android.bp b/transport/token/1.0/utils/Android.bp
index ab77a2a..101f3b4 100644
--- a/transport/token/1.0/utils/Android.bp
+++ b/transport/token/1.0/utils/Android.bp
@@ -15,6 +15,9 @@
cc_library {
name: "android.hidl.token@1.0-utils",
vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
srcs: [
"HybridInterface.cpp",
diff --git a/update-makefiles.sh b/update-makefiles.sh
index e82d24c..df3d4b1 100755
--- a/update-makefiles.sh
+++ b/update-makefiles.sh
@@ -4,6 +4,7 @@
android.hidl.allocator@1.0
android.hidl.base@1.0
android.hidl.manager@1.0
+ android.hidl.manager@1.1
android.hidl.memory@1.0
android.hidl.token@1.0
)