From 2b6d5dc6f782fa121e923d34205c94688ff25bd3 Mon Sep 17 00:00:00 2001 From: chennian Date: Wed, 29 Jun 2022 14:29:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9debug=20Signed-off-by:chennia?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chennian --- frameworks/common/BUILD.gn | 5 +- frameworks/common/include/constant_common.h | 41 ++++++++++++++++ frameworks/common/src/constant_common.cpp | 49 +++++++++++++++++++ services/privacymanager/BUILD.gn | 1 - .../privacymanager/include/common/constant.h | 2 - .../privacymanager/src/common/constant.cpp | 14 ------ services/tokensyncmanager/BUILD.gn | 1 - .../include/common/constant.h | 20 -------- .../tokensyncmanager/src/common/constant.cpp | 18 ------- 9 files changed, 94 insertions(+), 57 deletions(-) create mode 100644 frameworks/common/include/constant_common.h create mode 100644 frameworks/common/src/constant_common.cpp diff --git a/frameworks/common/BUILD.gn b/frameworks/common/BUILD.gn index e4c4118eb..598e7b585 100644 --- a/frameworks/common/BUILD.gn +++ b/frameworks/common/BUILD.gn @@ -40,7 +40,10 @@ ohos_shared_library("accesstoken_common_cxx") { "//third_party/mbedtls:mbedtls_shared", "//utils/native/base:utils", ] - external_deps = [ "hiviewdfx_hilog_native:libhilog" ] + external_deps = [ + "hiviewdfx_hilog_native:libhilog" + "startup_l2:syspara", + ] cflags_cc = [ "-DHILOG_ENABLE" ] } diff --git a/frameworks/common/include/constant_common.h b/frameworks/common/include/constant_common.h new file mode 100644 index 000000000..6f49db789 --- /dev/null +++ b/frameworks/common/include/constant_common.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 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. + */ + #ifdef FRAMEWORK_CONSTANT_COOM_H +#define FRAMEWORK_CONSTANT_COOM_H +namespace OHOS { +namespace Security { +namespace AccessToken { +class ConstantCommon { +public: + /** + * Device id length. + */ + const static int32_t DEVICE_UUID_LENGTH = 65; + + static constexpr int32_t ENCRYPTLEN = 4; + static constexpr int32_t ENCRYPTBEGIN = 0; + static constexpr int32_t ENCRYPTEND = 3; + static std::string EncryptDevId(std::string deviceId); + + /** + * GetLocalDeviceId + */ + static std::string GetLocalDeviceId(); +}; +} +} +} + +#endif \ No newline at end of file diff --git a/frameworks/common/src/constant_common.cpp b/frameworks/common/src/constant_common.cpp new file mode 100644 index 000000000..bf75cbefe --- /dev/null +++ b/frameworks/common/src/constant_common.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021-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 "constantconstant.h" +#include "parameter.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static const std::string REPLACE_TARGET = "****"; +} // namespace +std::string ConstantCommon::EncryptDevId(std::string deviceId) +{ + std::string result = deviceId; + if (deviceId.size() >= ENCRYPTLEN) { + result.replace(ENCRYPTBEGIN, ENCRYPTEND, REPLACE_TARGET); + } else { + result.replace(ENCRYPTBEGIN, result.size() - 1, REPLACE_TARGET); + } + return result; +} + +std::string ConstantCommon::GetLocalDeviceId() +{ + static std::string localDeviceId; + if (!localDeviceId.empty()) { + return localDeviceId; + } + const int32_t DEVICE_UUID_LENGTH = 65; + char udid[DEVICE_UUID_LENGTH] = {0}; + GetDevUdid(udid, DEVICE_UUID_LENGTH); + localDeviceId = udid; + return localDeviceId; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS \ No newline at end of file diff --git a/services/privacymanager/BUILD.gn b/services/privacymanager/BUILD.gn index 4cd608c62..9b7a978b4 100644 --- a/services/privacymanager/BUILD.gn +++ b/services/privacymanager/BUILD.gn @@ -63,6 +63,5 @@ ohos_shared_library("privacy_manager_service") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", - "startup_l2:syspara", ] } diff --git a/services/privacymanager/include/common/constant.h b/services/privacymanager/include/common/constant.h index 257286a18..ca7f375f0 100644 --- a/services/privacymanager/include/common/constant.h +++ b/services/privacymanager/include/common/constant.h @@ -67,8 +67,6 @@ public: public: static bool TransferPermissionToOpcode(const std::string& permissionName, int32_t& opCode); static bool TransferOpcodeToPermission(int32_t opCode, std::string& permissionName); - - static std::string GetLocalDeviceUdid(); }; } // namespace AccessToken } // namespace Security diff --git a/services/privacymanager/src/common/constant.cpp b/services/privacymanager/src/common/constant.cpp index f0aab8648..a9628adcd 100644 --- a/services/privacymanager/src/common/constant.cpp +++ b/services/privacymanager/src/common/constant.cpp @@ -14,7 +14,6 @@ */ #include "constant.h" -#include "parameter.h" namespace OHOS { namespace Security { @@ -70,19 +69,6 @@ bool Constant::TransferOpcodeToPermission(int32_t opCode, std::string& permissio permissionName = iter->first; return true; } - -std::string Constant::GetLocalDeviceUdid() -{ - static std::string localDeviceId; - if (!localDeviceId.empty()) { - return localDeviceId; - } - const int32_t DEVICE_UUID_LENGTH = 65; - char udid[DEVICE_UUID_LENGTH] = {0}; - GetDevUdid(udid, DEVICE_UUID_LENGTH); - localDeviceId = udid; - return localDeviceId; -} } // namespace AccessToken } // namespace Security } // namespace OHOS \ No newline at end of file diff --git a/services/tokensyncmanager/BUILD.gn b/services/tokensyncmanager/BUILD.gn index f829fbddf..ffb43c583 100644 --- a/services/tokensyncmanager/BUILD.gn +++ b/services/tokensyncmanager/BUILD.gn @@ -86,6 +86,5 @@ ohos_shared_library("token_sync_manager_service") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", - "startup_l2:syspara", ] } diff --git a/services/tokensyncmanager/include/common/constant.h b/services/tokensyncmanager/include/common/constant.h index 3a7d0d5e6..69d9353fe 100644 --- a/services/tokensyncmanager/include/common/constant.h +++ b/services/tokensyncmanager/include/common/constant.h @@ -68,26 +68,6 @@ public: * Command result string, indicates failed. */ static const std::string COMMAND_RESULT_FAILED; - - /** - * Device id length. - */ - const static int32_t DEVICE_UUID_LENGTH = 65; - - /** - * Command status code, indicate a status of command before RPC call. - */ - const static int32_t DELAY_SYNC_TOKEN_MS = 3000; - - static constexpr int32_t ENCRYPTLEN = 4; - static constexpr int32_t ENCRYPTBEGIN = 0; - static constexpr int32_t ENCRYPTEND = 3; - static std::string EncryptDevId(std::string deviceId); - - /** - * GetLocalDeviceId - */ - static std::string GetLocalDeviceId(); }; } // namespace AccessToken } // namespace Security diff --git a/services/tokensyncmanager/src/common/constant.cpp b/services/tokensyncmanager/src/common/constant.cpp index a20a7cc05..7de4ff187 100644 --- a/services/tokensyncmanager/src/common/constant.cpp +++ b/services/tokensyncmanager/src/common/constant.cpp @@ -23,24 +23,6 @@ static const std::string REPLACE_TARGET = "****"; } // namespace const std::string Constant::COMMAND_RESULT_SUCCESS = "success"; const std::string Constant::COMMAND_RESULT_FAILED = "execute command failed"; - -std::string Constant::EncryptDevId(std::string deviceId) -{ - std::string result = deviceId; - if (deviceId.size() >= ENCRYPTLEN) { - result.replace(ENCRYPTBEGIN, ENCRYPTEND, REPLACE_TARGET); - } else { - result.replace(ENCRYPTBEGIN, result.size() - 1, REPLACE_TARGET); - } - return result; -} - -std::string Constant::GetLocalDeviceId() -{ - char deviceIdCharArray[Constant::DEVICE_UUID_LENGTH] = {0}; - GetDevUdid(deviceIdCharArray, Constant::DEVICE_UUID_LENGTH); - return deviceIdCharArray; -} } // namespace AccessToken } // namespace Security } // namespace OHOS -- Gitee