DisplayConfig: Initialize service intf before registering service
Initialize service interface before calling registerservice so as
to avoid register client failure due to null service intf, which
can happen in some corner cases due to race condition.
Change-Id: Id3184845af293cb35cab497c1f7bb90eed561640
diff --git a/services/config/src/device_impl.cpp b/services/config/src/device_impl.cpp
index 02c3ebd..5d1fcdd 100644
--- a/services/config/src/device_impl.cpp
+++ b/services/config/src/device_impl.cpp
@@ -30,7 +30,7 @@
/*
* Changes from Qualcomm Innovation Center are provided under the following license:
*
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
@@ -82,13 +82,13 @@
return -1;
}
+ device_obj_->intf_ = intf;
android::status_t status = device_obj_->IDisplayConfig::registerAsService();
// Unable to start Display Config 2.0 service. Fail Init.
if (status != android::OK) {
device_obj_ = nullptr;
return -1;
}
- device_obj_->intf_ = intf;
}
return 0;