Add 1.1 version of hwservicemanager. am: 2a2678e402 am: 82f80df04c
am: 89a23c313f
Change-Id: I8275c509939cf6f0abeeedbde471b234f341a11a
diff --git a/manifest.xml b/manifest.xml
index 799b660..fb1ee39 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>
diff --git a/transport/Android.bp b/transport/Android.bp
index 73eee3a..2deb7cf 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",
@@ -47,14 +48,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..44a6f31 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) {
@@ -422,9 +426,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 +496,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 +520,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/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/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/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
)