1d9f0492fSopenharmony_ci/* 2d9f0492fSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3d9f0492fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4d9f0492fSopenharmony_ci * you may not use this file except in compliance with the License. 5d9f0492fSopenharmony_ci * You may obtain a copy of the License at 6d9f0492fSopenharmony_ci * 7d9f0492fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8d9f0492fSopenharmony_ci * 9d9f0492fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10d9f0492fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11d9f0492fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d9f0492fSopenharmony_ci * See the License for the specific language governing permissions and 13d9f0492fSopenharmony_ci * limitations under the License. 14d9f0492fSopenharmony_ci */ 15d9f0492fSopenharmony_ci#include "beget_ext.h" 16d9f0492fSopenharmony_ci#ifdef PARAM_FEATURE_DEVICEINFO 17d9f0492fSopenharmony_ci#include "device_info_kits.h" 18d9f0492fSopenharmony_ci#endif 19d9f0492fSopenharmony_ci#include "param_comm.h" 20d9f0492fSopenharmony_ci#include "securec.h" 21d9f0492fSopenharmony_ci#include "sysparam_errno.h" 22d9f0492fSopenharmony_ci 23d9f0492fSopenharmony_ci#ifdef __cplusplus 24d9f0492fSopenharmony_ci#if __cplusplus 25d9f0492fSopenharmony_ciextern "C" { 26d9f0492fSopenharmony_ci#endif 27d9f0492fSopenharmony_ci#endif /* __cplusplus */ 28d9f0492fSopenharmony_ci 29d9f0492fSopenharmony_ciint AclGetDevUdid(char *udid, int size) 30d9f0492fSopenharmony_ci{ 31d9f0492fSopenharmony_ci if (udid == nullptr || size < UDID_LEN) { 32d9f0492fSopenharmony_ci return SYSPARAM_INVALID_INPUT; 33d9f0492fSopenharmony_ci } 34d9f0492fSopenharmony_ci (void)memset_s(udid, size, 0, size); 35d9f0492fSopenharmony_ci#ifdef PARAM_FEATURE_DEVICEINFO 36d9f0492fSopenharmony_ci std::string result = {}; 37d9f0492fSopenharmony_ci OHOS::device_info::DeviceInfoKits &instance = OHOS::device_info::DeviceInfoKits::GetInstance(); 38d9f0492fSopenharmony_ci int ret = instance.GetUdid(result); 39d9f0492fSopenharmony_ci if (ret == 0) { 40d9f0492fSopenharmony_ci ret = strcpy_s(udid, size, result.c_str()); 41d9f0492fSopenharmony_ci } 42d9f0492fSopenharmony_ci#else 43d9f0492fSopenharmony_ci int ret = GetDevUdid_(udid, size); 44d9f0492fSopenharmony_ci#endif 45d9f0492fSopenharmony_ci return ret; 46d9f0492fSopenharmony_ci} 47d9f0492fSopenharmony_ci 48d9f0492fSopenharmony_ciconst char *AclGetSerial(void) 49d9f0492fSopenharmony_ci{ 50d9f0492fSopenharmony_ci static char serialNumber[MAX_SERIAL_LEN] = {0}; 51d9f0492fSopenharmony_ci#ifdef PARAM_FEATURE_DEVICEINFO 52d9f0492fSopenharmony_ci std::string result = {}; 53d9f0492fSopenharmony_ci OHOS::device_info::DeviceInfoKits &instance = OHOS::device_info::DeviceInfoKits::GetInstance(); 54d9f0492fSopenharmony_ci int ret = instance.GetSerialID(result); 55d9f0492fSopenharmony_ci if (ret == 0) { 56d9f0492fSopenharmony_ci ret = strcpy_s(serialNumber, sizeof(serialNumber), result.c_str()); 57d9f0492fSopenharmony_ci BEGET_ERROR_CHECK(ret == 0, return nullptr, "Failed to copy"); 58d9f0492fSopenharmony_ci } 59d9f0492fSopenharmony_ci#else 60d9f0492fSopenharmony_ci const char *tmpSerial = GetSerial_(); 61d9f0492fSopenharmony_ci if (tmpSerial != nullptr) { 62d9f0492fSopenharmony_ci int ret = strcpy_s(serialNumber, sizeof(serialNumber), tmpSerial); 63d9f0492fSopenharmony_ci BEGET_ERROR_CHECK(ret == 0, return nullptr, "Failed to copy"); 64d9f0492fSopenharmony_ci } 65d9f0492fSopenharmony_ci#endif 66d9f0492fSopenharmony_ci return serialNumber; 67d9f0492fSopenharmony_ci} 68d9f0492fSopenharmony_ci 69d9f0492fSopenharmony_ci#ifdef __cplusplus 70d9f0492fSopenharmony_ci#if __cplusplus 71d9f0492fSopenharmony_ci} 72d9f0492fSopenharmony_ci#endif 73d9f0492fSopenharmony_ci#endif /* __cplusplus */ 74