From 820f3addc9d73c8bfea493b33c0867ad4af7f5ac Mon Sep 17 00:00:00 2001 From: zhanglei Date: Thu, 22 May 2025 17:40:50 +0800 Subject: [PATCH 1/3] update Signed-off-by: zhanglei --- common/src/constants/distributed_device_profile_constants.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/constants/distributed_device_profile_constants.cpp b/common/src/constants/distributed_device_profile_constants.cpp index 62bd445c..369d4a99 100644 --- a/common/src/constants/distributed_device_profile_constants.cpp +++ b/common/src/constants/distributed_device_profile_constants.cpp @@ -375,7 +375,7 @@ const std::string ALTER_TABLE_ACEE_ADD_COLUMN_ACEE_DEVICE_NAME = const std::string ALTER_TABLE_ACEE_ADD_COLUMN_ACEE_SERVICE_NAME = "ALTER TABLE accessee_table ADD COLUMN accesseeServiceName TEXT DEFAULT ''"; const std::string ALTER_TABLE_ACEE_ADD_COLUMN_ACEE_CREDENTIAL_ID = - "ALTER TABLE accessee_table ADD COLUMN accesserCredentialId INTERGER DEFAULT -1"; + "ALTER TABLE accessee_table ADD COLUMN accesseeCredentialId INTERGER DEFAULT -1"; const std::string ALTER_TABLE_ACEE_ADD_COLUMN_ACEE_CREDENTIAL_ID_STR = "ALTER TABLE accessee_table ADD COLUMN accesseeCredentialIdStr TEXT DEFAULT ''"; const std::string ALTER_TABLE_ACEE_ADD_COLUMN_ACEE_STATUS = -- Gitee From b9c15adc9b1a46eb0f9342453693263fe5eaf6ec Mon Sep 17 00:00:00 2001 From: zhanglei Date: Fri, 23 May 2025 10:57:17 +0800 Subject: [PATCH 2/3] update Signed-off-by: zhanglei --- .../distributed_device_profile_constants.h | 1 + .../distributed_device_profile_constants.cpp | 1 + .../trust_profile_manager.h | 2 + .../trust_profile_manager.cpp | 40 +++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/common/include/constants/distributed_device_profile_constants.h b/common/include/constants/distributed_device_profile_constants.h index ac16a04f..02c274d8 100644 --- a/common/include/constants/distributed_device_profile_constants.h +++ b/common/include/constants/distributed_device_profile_constants.h @@ -339,6 +339,7 @@ extern const std::string CREATE_TURST_DEVICE_TABLE_UNIQUE_INDEX_SQL; extern const std::string CREATE_ACCESS_CONTROL_TABLE_UNIQUE_INDEX_SQL; extern const std::string CREATE_ACCESSER_TABLE_UNIQUE_INDEX_SQL; extern const std::string CREATE_ACCESSEE_TABLE_UNIQUE_INDEX_SQL; +extern const std::string PRAGMA_ACCESSEE_TABLE; extern const std::string DROP_OLD_UNIQUE_INDEX_ON_ACER; extern const std::string DROP_OLD_UNIQUE_INDEX_ON_ACEE; extern const std::string ALTER_TABLE_ACCESS_CONTROL_ADD_COLUMN_EXTRA_DATA; diff --git a/common/src/constants/distributed_device_profile_constants.cpp b/common/src/constants/distributed_device_profile_constants.cpp index 369d4a99..87ad9c09 100644 --- a/common/src/constants/distributed_device_profile_constants.cpp +++ b/common/src/constants/distributed_device_profile_constants.cpp @@ -350,6 +350,7 @@ const std::string CREATE_ACCESSEE_TABLE_UNIQUE_INDEX_SQL = accesseeCredentialIdStr,\ accesseeStatus,\ accesseeSessionKeyId);"; +const std::string PRAGMA_ACCESSEE_TABLE = "PRAGMA table_info(accessee_table)"; const std::string DROP_OLD_UNIQUE_INDEX_ON_ACER = "DROP INDEX unique_accesser_table"; const std::string DROP_OLD_UNIQUE_INDEX_ON_ACEE = "DROP INDEX unique_accessee_table"; const std::string ALTER_TABLE_ACCESS_CONTROL_ADD_COLUMN_EXTRA_DATA = diff --git a/services/core/include/trustprofilemanager/trust_profile_manager.h b/services/core/include/trustprofilemanager/trust_profile_manager.h index c1464b39..30801df3 100644 --- a/services/core/include/trustprofilemanager/trust_profile_manager.h +++ b/services/core/include/trustprofilemanager/trust_profile_manager.h @@ -128,6 +128,8 @@ private: int32_t NotifyCheck(const AccessControlProfile& profile, const AccessControlProfile& oldProfile); void RemoveLnnAcl(std::vector& profiles); bool IsLnnAcl(const AccessControlProfile& aclProfile); + bool IsAcerCreIdExistToAceeTable(); + int32_t AddAceeCreIdColumnToAceeTable(); private: std::shared_ptr rdbStore_; diff --git a/services/core/src/trustprofilemanager/trust_profile_manager.cpp b/services/core/src/trustprofilemanager/trust_profile_manager.cpp index 2a3b64f5..fe5b86f7 100644 --- a/services/core/src/trustprofilemanager/trust_profile_manager.cpp +++ b/services/core/src/trustprofilemanager/trust_profile_manager.cpp @@ -30,6 +30,7 @@ namespace DistributedDeviceProfile { IMPLEMENT_SINGLE_INSTANCE(TrustProfileManager); namespace { const std::string TAG = "TrustProfileManager"; + const std::string NAME = "name"; } int32_t TrustProfileManager::Init() @@ -49,6 +50,10 @@ int32_t TrustProfileManager::Init() } this->CreateTable(); this->CreateUniqueIndex(); + if (IsAcerCreIdExistToAceeTable() && AddAceeCreIdColumnToAceeTable() != DP_SUCCESS) { + HILOGI("acee table add aceeCreId failed"); + return DP_CREATE_TABLE_FAIL; + } HILOGI("end!"); return DP_SUCCESS; } @@ -2177,5 +2182,40 @@ bool TrustProfileManager::IsLnnAcl(const AccessControlProfile& aclProfile) cJSON_Delete(json); return false; } + +bool TrustProfileManager::IsAcerCreIdExistToAceeTable() +{ + std::shared_ptr resultSet = GetResultSet(PRAGMA_ACCESSEE_TABLE, std::vector{}); + if (resultSet == nullptr) { + HILOGE("resultSet is nullptr"); + return false; + } + while (resultSet->GoToNextRow() == DP_SUCCESS) { + int32_t columnIndex = COLUMNINDEX_INIT; + std::string columnName; + resultSet->GetColumnIndex(NAME, columnIndex); + resultSet->GetString(columnIndex, columnName); + if (columnName == ACCESSER_CREDENTIAL_ID) { + HILOGE("acerCreId exist to acee_table"); + return true; + } + } + return false; +} + +int32_t TrustProfileManager::AddAceeCreIdColumnToAceeTable() +{ + std::lock_guard lock(rdbMutex_); + if (rdbStore_ == nullptr) { + HILOGE("rdbStore_ is nullptr"); + return DP_GET_RDBSTORE_FAIL; + } + int32_t ret = rdbStore_->CreateTable(ALTER_TABLE_ACEE_ADD_COLUMN_ACEE_CREDENTIAL_ID); + if (ret != DP_SUCCESS) { + HILOGE("add column accesseeCredentialId to acee table failed"); + return DP_CREATE_TABLE_FAIL; + } + return DP_SUCCESS; +} } // namespace DistributedDeviceProfile } // namespace OHOS \ No newline at end of file -- Gitee From c4eb31a99522554869106b4e83eba3b0c2f9c144 Mon Sep 17 00:00:00 2001 From: zhanglei Date: Sat, 24 May 2025 11:37:35 +0800 Subject: [PATCH 3/3] update Signed-off-by: zhanglei --- services/core/src/trustprofilemanager/trust_profile_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/src/trustprofilemanager/trust_profile_manager.cpp b/services/core/src/trustprofilemanager/trust_profile_manager.cpp index fe5b86f7..395048f9 100644 --- a/services/core/src/trustprofilemanager/trust_profile_manager.cpp +++ b/services/core/src/trustprofilemanager/trust_profile_manager.cpp @@ -51,7 +51,7 @@ int32_t TrustProfileManager::Init() this->CreateTable(); this->CreateUniqueIndex(); if (IsAcerCreIdExistToAceeTable() && AddAceeCreIdColumnToAceeTable() != DP_SUCCESS) { - HILOGI("acee table add aceeCreId failed"); + HILOGE("acee table add aceeCreId failed"); return DP_CREATE_TABLE_FAIL; } HILOGI("end!"); -- Gitee