add bootevent

Signed-off-by: l00889714 <linzhaosheng@huawei.com>
Change-Id: I80e15008a0e5e1351bbc818df340d1729055013a
This commit is contained in:
l00889714 2024-11-18 16:39:56 +08:00
parent 5bbc98561f
commit 60e0754cfa
7 changed files with 78 additions and 2 deletions

View File

@ -86,7 +86,8 @@
"openssl",
"bounds_checking_function",
"mbedtls",
"cJSON"
"cJSON",
"init"
]
},
"build": {
@ -96,6 +97,7 @@
"//base/security/huks:fwk_group"
],
"service_group": [
"//base/security/huks/etc:param_files",
"//base/security/huks:service_group"
]
},

35
etc/BUILD.gn Normal file
View File

@ -0,0 +1,35 @@
# Copyright (c) 2024 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.
import("//build/ohos.gni")
group("param_files") {
deps = [
":huks.para",
":huks.para.dac",
]
}
ohos_prebuilt_etc("huks.para") {
source = "huks.para"
relative_install_dir = "param"
part_name = "huks"
subsystem_name = "security"
}
ohos_prebuilt_etc("huks.para.dac") {
source = "huks.para.dac"
relative_install_dir = "param"
part_name = "huks"
subsystem_name = "security"
}

14
etc/huks.para Normal file
View File

@ -0,0 +1,14 @@
# Copyright (c) 2024 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.
bootevent.huksService.ready=false

14
etc/huks.para.dac Normal file
View File

@ -0,0 +1,14 @@
# Copyright (c) 2024 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.
bootevent.huksService.ready=huks_server:huks_server:777

View File

@ -17,6 +17,9 @@
"path" : ["/system/bin/sa_main", "/system/profile/huks_service.json"],
"uid" : "huks_server",
"gid" : ["huks_server"],
"bootevents": [
"bootevent.huksService.ready"
],
"permission" : [
"ohos.permission.USE_USER_IDM",
"ohos.permission.MANAGE_LOCAL_ACCOUNTS",

View File

@ -90,6 +90,7 @@ if (os_level == "standard") {
]
external_deps += [
"hilog:libhilog",
"init:libbegetutil",
"ipc:ipc_single",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",

View File

@ -20,7 +20,7 @@
#include <mutex>
#include <string_ex.h>
#include <system_ability_definition.h>
#include "parameters.h"
#include "hks_client_service.h"
#include "hks_dcm_callback_handler.h"
#include "hks_ipc_service.h"
@ -63,6 +63,9 @@ uint32_t g_sessionId = 0;
namespace OHOS {
namespace Security {
namespace Hks {
const std::string BOOTEVENT_HUKSSERVICE_READY = "bootevent.huksService.ready";
REGISTER_SYSTEM_ABILITY_BY_ID(HksService, SA_ID_KEYSTORE_SERVICE, true);
std::mutex HksService::instanceLock;
@ -182,6 +185,10 @@ bool HksService::Init()
HKS_LOG_I("HksService::Init Publish service success");
registerToService_ = true;
if (!system::GetBoolParameter(BOOTEVENT_HUKSSERVICE_READY.c_str(), false)) {
system::SetParameter(BOOTEVENT_HUKSSERVICE_READY.c_str(), "true");
HKS_LOG_E("set bootevent.huksService.ready true");
}
HKS_LOG_I("HksService::Init success.");
return true;
}