diff --git a/bundle.json b/bundle.json index 2237dabb467bcd62818be04178b85ff67d695149..cba9724c19ecc642915bcd28175d3ad15c9d7ecb 100644 --- a/bundle.json +++ b/bundle.json @@ -36,6 +36,7 @@ "hisysevent", "hitrace", "huks", + "init", "ipc", "safwk", "samgr" @@ -54,6 +55,7 @@ "service_group": [ "//base/security/device_security_level/oem_property/ohos:dslm_service", "//base/security/device_security_level/oem_property/ohos:dslm_ohos_cred_file", + "//base/security/device_security_level/param:param_files", "//base/security/device_security_level/profile:dslm_service.rc" ] }, diff --git a/interfaces/inner_api/BUILD.gn b/interfaces/inner_api/BUILD.gn index db7e859fee1404cca0ef7740a66720a176ad0576..e5b15a09bb6b8c4a0018ddd11cca6ac75b125c7b 100644 --- a/interfaces/inner_api/BUILD.gn +++ b/interfaces/inner_api/BUILD.gn @@ -129,6 +129,7 @@ if (defined(ohos_lite)) { external_deps = [ "c_utils:utils", "hilog:libhilog", + "init:libbegetutil", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/interfaces/inner_api/include/device_security_info.h b/interfaces/inner_api/include/device_security_info.h index ba3428453ca276cf556e8fb1e773964b8beb72f5..23e25f43a34ec2da2f7acf08a2db89af8aed799b 100644 --- a/interfaces/inner_api/include/device_security_info.h +++ b/interfaces/inner_api/include/device_security_info.h @@ -67,6 +67,19 @@ void FreeDeviceSecurityInfo(DeviceSecurityInfo *info); */ int32_t GetDeviceSecurityLevelValue(const DeviceSecurityInfo *info, int32_t *level); +/** + * Gets the device security level from param. + * @param [out] level Device security level. + * @return + */ +int32_t GetSelfDeviceSecurityLevelValue(int32_t *level); + +/** + * Judge the device security level changeable. + * @return + */ +int32_t IsDeviceSecurityLevelChangeable(const char *udid, int32_t level); + #ifdef __cplusplus } #endif diff --git a/interfaces/inner_api/src/standard/device_security_info.cpp b/interfaces/inner_api/src/standard/device_security_info.cpp index 3118cb2bcc6a157503ac2fc46041079a2b7d2f3e..d2edb45a6bcb1f344c4c333dc7cb9ee0c414b806 100644 --- a/interfaces/inner_api/src/standard/device_security_info.cpp +++ b/interfaces/inner_api/src/standard/device_security_info.cpp @@ -18,6 +18,7 @@ #include #include "hilog/log.h" +#include "parameter.h" #include "device_security_level_callback_helper.h" #include "device_security_level_callback_stub.h" @@ -111,6 +112,23 @@ static int32_t GetDeviceSecurityLevelValueImpl(const DeviceSecurityInfo *info, i return static_cast(info->result); } +int32_t GetSelfDeviceSecurityLevelValueImpl(int32_t *level) +{ + const char key[128] = "const.security.device_security_level"; + int32_t def = 0; + int32_t levelGet = GetIntParameter(key, def); + *level = levelGet; + if (levelGet == -1) { + return -1; + } + return 0; +} + +int32_t IsDeviceSecurityLevelChangeableImpl(const char *udid, int32_t level) +{ + return 0; +} + #ifdef __cplusplus extern "C" { #endif @@ -137,6 +155,16 @@ int32_t GetDeviceSecurityLevelValue(const DeviceSecurityInfo *info, int32_t *lev return GetDeviceSecurityLevelValueImpl(info, level); } +int32_t GetSelfDeviceSecurityLevelValue(int32_t *level) +{ + return GetSelfDeviceSecurityLevelValueImpl(level); +} + +int32_t IsDeviceSecurityLevelChangeable(const char *udid, int32_t level) +{ + return IsDeviceSecurityLevelChangeableImpl(udid, level); +} + #ifdef __cplusplus } #endif diff --git a/param/BUILD.gn b/param/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2619f76e4e40f5264e7aaaefe9a0c61fc37fd977 --- /dev/null +++ b/param/BUILD.gn @@ -0,0 +1,28 @@ +# 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") + +## Install device_security_level.para to /system/etc/param/device_security_level.para + +group("param_files") { + deps = [ ":device_security_level.para" ] +} + +ohos_prebuilt_etc("device_security_level.para") { + source = "device_security_level.para" + + relative_install_dir = "param" + part_name = "device_security_level" + subsystem_name = "security" +} diff --git a/param/device_security_level.para b/param/device_security_level.para new file mode 100644 index 0000000000000000000000000000000000000000..c04f0d7d11636504ad8e367a4b9cf32faa47bb97 --- /dev/null +++ b/param/device_security_level.para @@ -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. + +const.security.device_security_level = 1 \ No newline at end of file