diff --git a/interfaces/hals/utils/sys_param/BUILD.gn b/interfaces/hals/utils/sys_param/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..73e041b58442a860991c8fdb16ce7d7dbd50f2dd --- /dev/null +++ b/interfaces/hals/utils/sys_param/BUILD.gn @@ -0,0 +1,26 @@ +# +# Copyright (c) 2020-2022 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. + +static_library("hal_sys_param") { + sources = [ "hal_sys_param.c" ] + include_dirs = [ "//base/startup/init/interfaces/hals" ] + defines = [ + "INCREMENTAL_VERSION=\"${ohos_version}\"", + "BUILD_TYPE=\"${ohos_build_type}\"", + "BUILD_USER=\"${ohos_build_user}\"", + "BUILD_TIME=\"${ohos_build_time}\"", + "BUILD_HOST=\"${ohos_build_host}\"", + "BUILD_ROOTHASH=\"${ohos_build_roothash}\"", + ] +} diff --git a/interfaces/hals/utils/sys_param/hal_sys_param.c b/interfaces/hals/utils/sys_param/hal_sys_param.c new file mode 100644 index 0000000000000000000000000000000000000000..a373b0b217e16e24bc3e9a161b92e220e7191ef1 --- /dev/null +++ b/interfaces/hals/utils/sys_param/hal_sys_param.c @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2020-2022 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 "hal_sys_param.h" + +static const char OHOS_ABI_LIST[] = {"****"}; +static const char OHOS_BOOTLOADER_VERSION[] = {"bootloader"}; +static const char OHOS_BRAND[] = {"****"}; +static const char OHOS_DEVICE_TYPE[] = {"****"}; +static const char OHOS_DISPLAY_VERSION[] = {"OpenHarmony 3.1"}; +static const char OHOS_HARDWARE_MODEL[] = {"****"}; +static const char OHOS_HARDWARE_PROFILE[] = {"aout:true,display:true"}; +static const char OHOS_MARKET_NAME[] = {"****"}; +static const char OHOS_MANUFACTURE[] = {"****"}; +static const char OHOS_PRODUCT_MODEL[] = {"****"}; +static const char OHOS_PRODUCT_SERIES[] = {"****"}; +static const char OHOS_SERIAL[] = {"****"}; // provided by OEM. +static const char OHOS_SOFTWARE_MODEL[] = {"****"}; +static const int OHOS_FIRST_API_VERSION = 1; + +__attribute__((weak)) const char* HalGetDeviceType(void) +{ + return OHOS_DEVICE_TYPE; +} + +__attribute__((weak)) const char* HalGetManufacture(void) +{ + return OHOS_MANUFACTURE; +} + +__attribute__((weak)) const char* HalGetBrand(void) +{ + return OHOS_BRAND; +} + +__attribute__((weak)) const char* HalGetMarketName(void) +{ + return OHOS_MARKET_NAME; +} + +__attribute__((weak)) const char* HalGetProductSeries(void) +{ + return OHOS_PRODUCT_SERIES; +} + +__attribute__((weak)) const char* HalGetProductModel(void) +{ + return OHOS_PRODUCT_MODEL; +} + +__attribute__((weak)) const char* HalGetSoftwareModel(void) +{ + return OHOS_SOFTWARE_MODEL; +} + +__attribute__((weak)) const char* HalGetHardwareModel(void) +{ + return OHOS_HARDWARE_MODEL; +} + +__attribute__((weak)) const char* HalGetHardwareProfile(void) +{ + return OHOS_HARDWARE_PROFILE; +} + +__attribute__((weak)) const char* HalGetSerial(void) +{ + return OHOS_SERIAL; +} + +__attribute__((weak)) const char* HalGetBootloaderVersion(void) +{ + return OHOS_BOOTLOADER_VERSION; +} + +__attribute__((weak)) const char* HalGetAbiList(void) +{ + return OHOS_ABI_LIST; +} + +__attribute__((weak)) const char* HalGetDisplayVersion(void) +{ + return OHOS_DISPLAY_VERSION; +} + +__attribute__((weak)) const char* HalGetIncrementalVersion(void) +{ + return INCREMENTAL_VERSION; +} + +__attribute__((weak)) const char* HalGetBuildType(void) +{ + return BUILD_TYPE; +} + +__attribute__((weak)) const char* HalGetBuildUser(void) +{ + return BUILD_USER; +} + +__attribute__((weak)) const char* HalGetBuildHost(void) +{ + return BUILD_HOST; +} + +__attribute__((weak)) const char* HalGetBuildTime(void) +{ + return BUILD_TIME; +} + +__attribute__((weak)) int HalGetFirstApiVersion(void) +{ + return OHOS_FIRST_API_VERSION; +} \ No newline at end of file diff --git a/interfaces/hals/utils/token/BUILD.gn b/interfaces/hals/utils/token/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..95c818a966a659e44809cc8652149e8d8de69e54 --- /dev/null +++ b/interfaces/hals/utils/token/BUILD.gn @@ -0,0 +1,22 @@ +# +# Copyright (c) 2020-2022 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. + +static_library("static_hal_token") { + sources = [ "hal_token.c" ] + include_dirs = [ + "//base/startup/init/interfaces/hals", + "//commonlibrary/utils_lite/include", + ] + deps = [] +} diff --git a/interfaces/hals/utils/token/hal_token.c b/interfaces/hals/utils/token/hal_token.c new file mode 100644 index 0000000000000000000000000000000000000000..99512a5edeb639db0ec76b24a01ddc61b4aedd3b --- /dev/null +++ b/interfaces/hals/utils/token/hal_token.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2020-2022 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 "hal_token.h" +#include "ohos_errno.h" +#include "ohos_types.h" + +__attribute__((weak)) static int OEMReadToken(char* token, unsigned int len) +{ + // OEM need add here, read token from device + (void)(token); + (void)(len); + return EC_SUCCESS; +} + +__attribute__((weak)) static int OEMWriteToken(const char* token, unsigned int len) +{ + // OEM need add here, write token to device + (void)(token); + (void)(len); + return EC_SUCCESS; +} + +__attribute__((weak)) static int OEMGetAcKey(char* acKey, unsigned int len) +{ + // OEM need add here, get AcKey + (void)(acKey); + (void)(len); + return EC_SUCCESS; +} + +__attribute__((weak)) static int OEMGetProdId(char* productId, unsigned int len) +{ + // OEM need add here, get ProdId + (void)(productId); + (void)(len); + return EC_SUCCESS; +} + +__attribute__((weak)) static int OEMGetProdKey(char* productKey, unsigned int len) +{ + // OEM need add here, get ProdKey + (void)(productKey); + (void)(len); + return EC_SUCCESS; +} + +__attribute__((weak)) int HalReadToken(char* token, unsigned int len) +{ + if (token == NULL) { + return EC_FAILURE; + } + + return OEMReadToken(token, len); +} + +__attribute__((weak)) int HalWriteToken(const char* token, unsigned int len) +{ + if (token == NULL) { + return EC_FAILURE; + } + + return OEMWriteToken(token, len); +} + +__attribute__((weak)) int HalGetAcKey(char* acKey, unsigned int len) +{ + if (acKey == NULL) { + return EC_FAILURE; + } + + return OEMGetAcKey(acKey, len); +} + +__attribute__((weak)) int HalGetProdId(char* productId, unsigned int len) +{ + if (productId == NULL) { + return EC_FAILURE; + } + + return OEMGetProdId(productId, len); +} + +__attribute__((weak)) int HalGetProdKey(char* productKey, unsigned int len) +{ + if (productKey == NULL) { + return EC_FAILURE; + } + + return OEMGetProdKey(productKey, len); +} \ No newline at end of file diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index 99e9d53796d86baab2a669d7029c0889a3561c36..562e42960923583dd20bb33a482f73273266df75 100755 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -111,7 +111,17 @@ if (defined(ohos_lite)) { sources = [] if (enable_ohos_startup_init_feature_begetctl_liteos) { - deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ] + PRODUCT_HAL_SYSPARAM_PATH = + rebase_path("//${ohos_product_adapter_dir}/utils/sys_param") + cmd = "if [ -f ${PRODUCT_HAL_SYSPARAM_PATH}/BUILD.gn ]; then echo true; else echo false; fi" + PRODUCT_HAL_SYSPARAM_EXISTS = + exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") + if (PRODUCT_HAL_SYSPARAM_EXISTS) { + deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ] + } + deps += [ + "//base/startup/init/interfaces/hals/utils/sys_param:hal_sys_param", + ] defines += [ "LITEOS_SUPPORT" ] sources += syspara_sources } else { diff --git a/interfaces/innerkits/token/BUILD.gn b/interfaces/innerkits/token/BUILD.gn index 6fa2ae9f37cd1dc419cabb390054f5659198e3b2..9c9d741f643dae11851072fada443325cd028a36 100755 --- a/interfaces/innerkits/token/BUILD.gn +++ b/interfaces/innerkits/token/BUILD.gn @@ -44,8 +44,16 @@ if (ohos_kernel_type == "liteos_m") { "//base/startup/init/interfaces/innerkits/token", "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite", ] - - deps = [ "$ohos_product_adapter_dir/utils/token:hal_token_static" ] + PRODUCT_HAL_TOKEN_PATH = + rebase_path("//${ohos_product_adapter_dir}/utils/token") + cmd = "if [ -f ${PRODUCT_HAL_TOKEN_PATH}/BUILD.gn ]; then echo true; else echo false; fi" + PRODUCT_HAL_TOKEN_EXISTS = + exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") + if (PRODUCT_HAL_TOKEN_EXISTS) { + deps += [ "$ohos_product_adapter_dir/utils/token:hal_token_static" ] + } + deps += + [ "//base/startup/init/interfaces/hals/utils/token:static_hal_token" ] } } diff --git a/test/unittest/lite/BUILD.gn b/test/unittest/lite/BUILD.gn index db734a0093b046a963599b68f77114a2f55d471e..563bd677406e9ed57d856e4c54f4172496b932b9 100755 --- a/test/unittest/lite/BUILD.gn +++ b/test/unittest/lite/BUILD.gn @@ -142,10 +142,19 @@ if (defined(ohos_lite)) { # add cfg.h if (enable_ohos_startup_init_feature_begetctl_liteos) { + PRODUCT_HAL_SYSPARAM_PATH = + rebase_path("//${ohos_product_adapter_dir}/utils/sys_param") + cmd = "if [ -f ${PRODUCT_HAL_SYSPARAM_PATH}/BUILD.gn ]; then echo true; else echo false; fi" + PRODUCT_HAL_SYSPARAM_EXISTS = + exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") + if (PRODUCT_HAL_SYSPARAM_EXISTS) { + deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ] + } deps += [ - "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam", - "//base/startup/init/services/param/liteos:lite_ohos_param_to", + "//base/startup/init/interfaces/hals/utils/sys_param:hal_sys_param", ] + deps += + [ "//base/startup/init/services/param/liteos:lite_ohos_param_to" ] include_dirs += [ "$root_out_dir/gen/init" ] defines += [ "PARAM_LOAD_CFG_FROM_CODE" ] }