diff --git a/frameworks/common/BUILD.gn b/frameworks/common/BUILD.gn index e4c4118eb251c8e65509996ee390761a3725dcc9..598e7b585fcf0acc7af38a3330c53797f6f7fad3 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 0000000000000000000000000000000000000000..6f49db7895239e166462ffa4c9f9d2c404ee6a56 --- /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 0000000000000000000000000000000000000000..bf75cbefe3d2f0f8e5f7df38e36ee082745dbf55 --- /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 4cd608c62191500d36f95ee30857dbd36d7cb589..9b7a978b472ec2879c54a7eab2e8e9919c603df1 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 257286a18367bed09899c44e6e25c6ba0f39d785..ca7f375f04032cde5f9581d838e83d7394348b35 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 f0aab86482f5fd5bca939bebc38d6a9b626e5437..a9628adcdf6c8bac79b59edb4ad0104e82efed18 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 f829fbddf8ae88e72575ebd808cdfa452dbf8893..ffb43c583fe6da38c9f8ebde56c7ab18ad8ca80e 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 3a7d0d5e60b3ca60022fbfc79d6352e6dc0a15d4..69d9353fea929b168a7676bd8dc7cead2f33853b 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 a20a7cc052547f48bc296da132c9ec33cb4c1711..7de4ff1875c7b4d030bad6818fd21e8175b1ce24 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