Implement @1.1::IServiceManager
This adds the ability to unregisterServiceNotifications.
By doing this, we can avoid unnecessary memory from being held
and also avoid unnecessary IPC calls.
Test: hidl_test
Test: boot a marlin
Bug: 63940457
Change-Id: I949a3fb50a5210138b623ab1654dc3e7a5f15e1c
diff --git a/ServiceManager.h b/ServiceManager.h
index 9fafadf..66225c5 100644
--- a/ServiceManager.h
+++ b/ServiceManager.h
@@ -1,7 +1,7 @@
-#ifndef ANDROID_HARDWARE_MANAGER_V1_0_SERVICEMANAGER_H
-#define ANDROID_HARDWARE_MANAGER_V1_0_SERVICEMANAGER_H
+#ifndef ANDROID_HARDWARE_MANAGER_SERVICEMANAGER_H
+#define ANDROID_HARDWARE_MANAGER_SERVICEMANAGER_H
-#include <android/hidl/manager/1.0/IServiceManager.h>
+#include <android/hidl/manager/1.1/IServiceManager.h>
#include <hidl/Status.h>
#include <hidl/MQDescriptor.h>
#include <map>
@@ -11,7 +11,6 @@
namespace android {
namespace hidl {
namespace manager {
-namespace V1_0 {
namespace implementation {
using ::android::hardware::hidl_death_recipient;
@@ -20,7 +19,7 @@
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hidl::base::V1_0::IBase;
-using ::android::hidl::manager::V1_0::IServiceManager;
+using ::android::hidl::manager::V1_1::IServiceManager;
using ::android::hidl::manager::V1_0::IServiceNotification;
using ::android::sp;
using ::android::wp;
@@ -47,9 +46,14 @@
Return<void> registerPassthroughClient(const hidl_string &fqName,
const hidl_string &name) override;
+ // Methods from ::android::hidl::manager::V1_1::IServiceManager follow.
+ Return<bool> unregisterForNotifications(const hidl_string& fqName,
+ const hidl_string& name,
+ const sp<IServiceNotification>& callback) override;
+
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who);
private:
- bool remove(const wp<IBase>& who);
+ bool removeService(const wp<IBase>& who);
bool removePackageListener(const wp<IBase>& who);
bool removeServiceListener(const wp<IBase>& who);
size_t countExistingService() const;
@@ -80,6 +84,7 @@
void addPackageListener(sp<IServiceNotification> listener);
bool removePackageListener(const wp<IBase>& who);
+ bool removeServiceListener(const wp<IBase>& who);
void sendPackageRegistrationNotification(
const hidl_string &fqName,
@@ -106,9 +111,8 @@
};
} // namespace implementation
-} // namespace V1_0
} // namespace manager
} // namespace hidl
} // namespace android
-#endif // ANDROID_HARDWARE_MANAGER_V1_0_SERVICEMANAGER_H
+#endif // ANDROID_HARDWARE_MANAGER_SERVICEMANAGER_H