mirror of
https://gitee.com/openharmony/window_window_manager
synced 2025-02-14 12:39:11 +00:00
fix: avoid duplicate registration and publication of window manager service SA
Signed-off-by: liuanguang <liuanguang@huawei.com> Change-Id: Ia6f9fc9e1cbd91ff8a3c648713dcdc3c273dd125
This commit is contained in:
parent
f317a1d358
commit
0fee3cdfec
@ -132,15 +132,29 @@ MockSessionManagerService::MockSessionManagerService()
|
||||
|
||||
bool MockSessionManagerService::RegisterMockSessionManagerService()
|
||||
{
|
||||
bool res = SystemAbility::MakeAndRegisterAbility(this);
|
||||
if (!res) {
|
||||
WLOGFE("register failed");
|
||||
static bool isRegistered = false;
|
||||
static bool isPublished = false;
|
||||
if (isRegistered && isPublished) {
|
||||
TLOGW(WmsLogTag::WMS_MULTI_USER, "WindowManagerService SA has already been registered and published");
|
||||
return true;
|
||||
}
|
||||
if (!Publish(this)) {
|
||||
WLOGFE("Publish failed");
|
||||
if (!isRegistered) {
|
||||
isRegistered = SystemAbility::MakeAndRegisterAbility(this);
|
||||
if (isRegistered) {
|
||||
TLOGI(WmsLogTag::WMS_MULTI_USER, "Successfully registered WindowManagerService SA");
|
||||
} else {
|
||||
TLOGE(WmsLogTag::WMS_MULTI_USER, "Failed to register WindowManagerService SA");
|
||||
}
|
||||
}
|
||||
WLOGFI("Publish mock session manager service success");
|
||||
return true;
|
||||
if (!isPublished) {
|
||||
isPublished = Publish(this);
|
||||
if (isPublished) {
|
||||
TLOGI(WmsLogTag::WMS_MULTI_USER, "Successfully published WindowManagerService SA");
|
||||
} else {
|
||||
TLOGE(WmsLogTag::WMS_MULTI_USER, "Failed to publish WindowManagerService SA");
|
||||
}
|
||||
}
|
||||
return isRegistered && isPublished;
|
||||
}
|
||||
|
||||
void MockSessionManagerService::OnStart()
|
||||
|
Loading…
x
Reference in New Issue
Block a user