From 46a1fb4f5980b99e6cdba4b120596834bbfcca5e Mon Sep 17 00:00:00 2001 From: guozejun Date: Sun, 26 Sep 2021 15:33:57 +0800 Subject: [PATCH] Optimiz libace.z.so load process Signed-off-by: guozejun Change-Id: If4d353fadb6165a69830875ff50e0123eec645e3 --- include/appspawn_server.h | 13 +++++++++++++ src/appspawn_server.cpp | 21 ++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/appspawn_server.h b/include/appspawn_server.h index c73cf79f..0f838c02 100644 --- a/include/appspawn_server.h +++ b/include/appspawn_server.h @@ -1,3 +1,11 @@ +/* + * @Author: your name + * @Date: 2021-09-18 11:54:34 + * @LastEditTime: 2021-09-26 15:28:25 + * @LastEditors: Please set LastEditors + * @Description: In User Settings Edit + * @FilePath: /appspawn_standard/include/appspawn_server.h + */ /* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -143,6 +151,11 @@ private: */ bool CheckAppProperty(const ClientSocket::AppProperty *appProperty); + /** + * Load libace.z.so library when boot the devices + */ + void LoadAceLib(); + private: const std::string deviceNull_ = "/dev/null"; std::string socketName_ {}; diff --git a/src/appspawn_server.cpp b/src/appspawn_server.cpp index c5071b05..3e0c88f9 100644 --- a/src/appspawn_server.cpp +++ b/src/appspawn_server.cpp @@ -28,6 +28,11 @@ #include "main_thread.h" #include "securec.h" +#if defined(ABILITY_LIBRARY_LOADER) || defined(APPLICATION_LIBRARY_LOADER) +#include +#include +#endif + #define GRAPHIC_PERMISSION_CHECK namespace OHOS { @@ -147,6 +152,20 @@ void AppSpawnServer::ConnectionPeer() } } +void AppSpawnServer::LoadAceLib() +{ + std::string acelibdir("/system/lib/libace.z.so"); + void *AceAbilityLib = nullptr; + HiLog::Info(LABEL, "MainThread::LoadAbilityLibrary. Start calling dlopen acelibdir."); + AceAbilityLib = dlopen(acelibdir.c_str(), RTLD_NOW | RTLD_GLOBAL); + if (AceAbilityLib == nullptr) { + HiLog::Error(LABEL, "Fail to dlopen %{public}s, [%{public}s]", acelibdir.c_str(), dlerror()); + } else { + HiLog::Info(LABEL, "Success to dlopen %{public}s", acelibdir.c_str()); + } + HiLog::Info(LABEL, "MainThread::LoadAbilityLibrary. End calling dlopen."); +} + bool AppSpawnServer::ServerMain(char *longProcName, int64_t longProcNameLen) { if (socket_->RegisterServerSocket() != 0) { @@ -154,7 +173,7 @@ bool AppSpawnServer::ServerMain(char *longProcName, int64_t longProcNameLen) return false; } std::thread(&AppSpawnServer::ConnectionPeer, this).detach(); - + LoadAceLib(); while (isRunning_) { std::unique_lock lock(mut_); dataCond_.wait(lock, [this] { return !this->appQueue_.empty(); }); -- Gitee