installd to standard sa

Signed-off-by: xsz233 <xushizhe@huawei.com>
This commit is contained in:
xsz233 2023-06-27 03:04:28 +00:00
parent 399ce8488a
commit dc5da459e1
10 changed files with 72 additions and 49 deletions

14
sa_profile/511.json Normal file
View File

@ -0,0 +1,14 @@
{
"process": "installs",
"systemability": [
{
"name": 511,
"libpath": "libinstalls.z.so",
"run-on-create": true,
"depend_time_out": 60000,
"distributed": false,
"bootphase": "CoreStartPhase",
"dump_level": 1
}
]
}

View File

@ -15,7 +15,10 @@ import("//build/ohos.gni")
import("//build/ohos/sa_profile/sa_profile.gni")
ohos_sa_profile("appexecfwk_sa_profile") {
sources = [ "401.json" ]
sources = [
"401.json",
"511.json",
]
part_name = "bundle_framework"
}

View File

@ -364,13 +364,18 @@ ohos_shared_library("libbms") {
part_name = "bundle_framework"
}
ohos_executable("installs") {
ohos_shared_library("installs") {
sources = [
"src/bundle_extractor.cpp",
"src/installd/installd_main.cpp",
"src/system_ability_helper.cpp",
]
use_exceptions = true
visibility = [
"//base/*",
"//foundation/*",
]
sources += install_daemon_sources
defines = [ "APP_LOG_TAG = \"BundleMgrService\"" ]
@ -389,6 +394,7 @@ ohos_executable("installs") {
"hilog:libhilog",
"init:libbegetutil",
"ipc:ipc_single",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]

View File

@ -21,6 +21,7 @@ install_daemon_sources = [
"${services_path}/bundlemgr/src/installd/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/src/installd/installd_service.cpp",
"${services_path}/bundlemgr/src/installd_client.cpp",
"${services_path}/bundlemgr/src/installd_death_recipient.cpp",
"${services_path}/bundlemgr/src/ipc/create_dir_param.cpp",
"${services_path}/bundlemgr/src/ipc/extract_param.cpp",
"${services_path}/bundlemgr/src/ipc/file_stat.cpp",

View File

@ -20,13 +20,23 @@
#include "installd/installd_host_impl.h"
#include "ipc/installd_host.h"
#include "system_ability.h"
namespace OHOS {
namespace AppExecFwk {
class InstalldService {
class InstalldService : public SystemAbility {
DECLARE_SYSTEM_ABILITY(InstalldService);
public:
InstalldService(int32_t saId, bool runOnCreate);
InstalldService();
virtual ~InstalldService();
void OnStart() override;
void OnStop() override;
/**
* @brief Start the installd service.
* @return

View File

@ -8,7 +8,7 @@
],
"services" : [{
"name" : "installs",
"path" : ["/system/bin/installs"],
"path" : ["/system/bin/sa_main", "/system/profile/installs.json"],
"importance" : -20,
"uid" : "installs",
"gid" : ["installs"],

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ipc_skeleton.h"
#include "app_log_wrapper.h"
#include "installd/installd_service.h"
int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
{
using namespace OHOS::AppExecFwk;
std::unique_ptr<InstalldService> service = std::make_unique<InstalldService>();
service->Start();
if (!service->IsServiceReady()) {
APP_LOGW("can't start the installd service, try again");
service->Start();
if (!service->IsServiceReady()) {
APP_LOGE("fail to start the installd service");
std::exit(EXIT_FAILURE);
}
}
OHOS::IPCSkeleton::JoinWorkThread();
service->Stop();
APP_LOGE("installd service stopped");
return EXIT_SUCCESS;
}

View File

@ -23,6 +23,7 @@
#include "app_log_wrapper.h"
#include "bundle_constants.h"
#include "installd/installd_operator.h"
#include "system_ability_definition.h"
#include "system_ability_helper.h"
@ -30,7 +31,18 @@ using namespace std::chrono_literals;
namespace OHOS {
namespace AppExecFwk {
InstalldService::InstalldService()
namespace {
const int32_t INSTALLD_ID = 511;
}
REGISTER_SYSTEM_ABILITY_BY_ID(InstalldService, INSTALLD_ID, true);
InstalldService::InstalldService(int32_t saId, bool runOnCreate) : SystemAbility(saId, runOnCreate)
{
APP_LOGI("installd service instance is created");
}
InstalldService::InstalldService() : SystemAbility(INSTALLD_ID, true)
{
APP_LOGI("installd service instance is created");
}
@ -40,6 +52,21 @@ InstalldService::~InstalldService()
APP_LOGI("installd service instance is destroyed");
}
void InstalldService::OnStart()
{
APP_LOGI("installd OnStart");
Start();
if (!Publish(hostImpl_)) {
APP_LOGI("Publish failed");
}
}
void InstalldService::OnStop()
{
Stop();
APP_LOGI("installd OnStop");
}
bool InstalldService::Init()
{
if (isReady_) {

View File

@ -22,7 +22,6 @@ ohos_unittest("BmsInstallDaemonTest") {
module_out_path = module_output_path
include_dirs = [ "//third_party/jsoncpp/include" ]
sources = [
"${services_path}/bundlemgr/src/installd_death_recipient.cpp",
"${services_path}/bundlemgr/test/mock/src/accesstoken_kit.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp",
@ -55,6 +54,7 @@ ohos_unittest("BmsInstallDaemonTest") {
"hilog:libhilog",
"init:libbegetutil",
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
defines = []
@ -105,6 +105,7 @@ ohos_unittest("BmsInstallDaemonIpcTest") {
"c_utils:utils",
"hilog:libhilog",
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
defines = []
@ -158,6 +159,7 @@ ohos_unittest("BmsInstallDaemonHostImplTest") {
"hilog:libhilog",
"init:libbegetutil",
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
defines = [ "BUNDLE_FRAMEWORK_RETURN_FALSE" ]

View File

@ -24,10 +24,7 @@ ohos_unittest("BmsInstalldClientTest") {
"//third_party/jsoncpp/include",
"${services_path}/bundlemgr/include",
]
sources = [
"${services_path}/bundlemgr/src/installd_death_recipient.cpp",
"${services_path}/bundlemgr/src/system_ability_helper.cpp",
]
sources = [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ]
sources += install_daemon_sources
@ -48,6 +45,7 @@ ohos_unittest("BmsInstalldClientTest") {
"hilog:libhilog",
"init:libbegetutil",
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
defines = []