Add addService to pass in dump priority flags.
Bug: 342937835
Test: Service can be added with dump priority critical or high.
Signed-off-by: Henry Wang <wangzhenghong@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:acb3a5a9b214fbb7c54e94afe77bf4fb0f0793eb)
Change-Id: I59a3fa3662ae253b5d2ab89071603a6e6eb81349
diff --git a/libs/binder/ndk/service_manager.cpp b/libs/binder/ndk/service_manager.cpp
index 5529455..4436dbe 100644
--- a/libs/binder/ndk/service_manager.cpp
+++ b/libs/binder/ndk/service_manager.cpp
@@ -49,7 +49,25 @@
sp<IServiceManager> sm = defaultServiceManager();
bool allowIsolated = flags & AServiceManager_AddServiceFlag::ADD_SERVICE_ALLOW_ISOLATED;
- status_t exception = sm->addService(String16(instance), binder->getBinder(), allowIsolated);
+ int dumpFlags = 0;
+ if (flags & AServiceManager_AddServiceFlag::ADD_SERVICE_DUMP_FLAG_PRIORITY_CRITICAL) {
+ dumpFlags |= IServiceManager::DUMP_FLAG_PRIORITY_CRITICAL;
+ }
+ if (flags & AServiceManager_AddServiceFlag::ADD_SERVICE_DUMP_FLAG_PRIORITY_HIGH) {
+ dumpFlags |= IServiceManager::DUMP_FLAG_PRIORITY_HIGH;
+ }
+ if (flags & AServiceManager_AddServiceFlag::ADD_SERVICE_DUMP_FLAG_PRIORITY_NORMAL) {
+ dumpFlags |= IServiceManager::DUMP_FLAG_PRIORITY_NORMAL;
+ }
+ if (flags & AServiceManager_AddServiceFlag::ADD_SERVICE_DUMP_FLAG_PRIORITY_DEFAULT) {
+ dumpFlags |= IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT;
+ }
+ if (dumpFlags == 0) {
+ dumpFlags = IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT;
+ }
+ status_t exception =
+ sm->addService(String16(instance), binder->getBinder(), allowIsolated, dumpFlags);
+
return PruneException(exception);
}