From 3587f940bd0204dc78eb2cd3a735397f593aa223 Mon Sep 17 00:00:00 2001 From: guxiang Date: Fri, 4 Jul 2025 16:19:45 +0800 Subject: [PATCH] distribute anco click and pc/pad collaborate optimised Signed-off-by: guxiang --- .../ans/src/notification_operation_info.cpp | 46 +++++- frameworks/ans/test/unittest/ans_log_test.cpp | 3 + .../notification_operation_info_test.cpp | 20 ++- .../core/common/include/ans_convert_enum.h | 5 +- .../core/common/src/ans_convert_enum.cpp | 3 + frameworks/js/napi/include/subscribe.h | 4 +- frameworks/js/napi/src/subscribe.cpp | 4 + .../js/napi/src/subscribe/napi_subscribe.cpp | 20 ++- interfaces/inner_api/notification_constant.h | 10 +- .../inner_api/notification_operation_info.h | 14 +- .../include/advanced_notification_service.h | 1 + .../ans/include/notification_preferences.h | 8 +- .../notification_preferences_database.h | 12 +- .../include/notification_subscriber_manager.h | 9 +- .../advanced_notification_cancel.cpp | 10 +- .../ans/src/advanced_notification_service.cpp | 3 +- ...tification_distributed_manager_service.cpp | 4 +- services/ans/src/notification_preferences.cpp | 8 +- .../src/notification_preferences_database.cpp | 32 ++-- .../src/notification_subscriber_manager.cpp | 38 +++-- ...ation_distributed_manager_service_test.cpp | 2 +- .../notification_subscriber_manager_test.cpp | 3 +- ...liveview_all_scenarios_extension_wrapper.h | 14 +- .../soft_bus/distributed_operation_service.h | 8 +- ...distributed_unlock_listener_oper_service.h | 11 +- .../distributed/include/tlv_box/request_box.h | 2 - .../include/tlv_box/response_box.h | 6 +- .../distributed/include/tlv_box/tlv_box.h | 4 +- ...veview_all_scenarios_extension_wrapper.cpp | 42 ++++-- .../distributed_operation_service.cpp | 137 ++++------------- .../distributed_publish_service_v2.cpp | 35 +---- .../src/soft_bus/distributed_subscriber.cpp | 9 +- ...stributed_unlock_listener_oper_service.cpp | 142 +++++++++++++++--- .../distributed/src/tlv_box/request_box.cpp | 29 ---- .../distributed/src/tlv_box/response_box.cpp | 34 ++--- 35 files changed, 436 insertions(+), 296 deletions(-) diff --git a/frameworks/ans/src/notification_operation_info.cpp b/frameworks/ans/src/notification_operation_info.cpp index 2dd14c208..4efaa13e2 100644 --- a/frameworks/ans/src/notification_operation_info.cpp +++ b/frameworks/ans/src/notification_operation_info.cpp @@ -80,11 +80,31 @@ int32_t NotificationOperationInfo::GetBtnIndex() const return btnIndex_; } -void NotificationOperationInfo::SetBtnIndex(const int32_t& btnIndex) +void NotificationOperationInfo::SetBtnIndex(const int32_t btnIndex) { btnIndex_ = btnIndex; } +int32_t NotificationOperationInfo::GetJumpType() const +{ + return jumpType_; +} + +void NotificationOperationInfo::SetJumpType(const int32_t jumpType) +{ + jumpType_ = jumpType; +} + +std::string NotificationOperationInfo::GetNotificationUdid() const +{ + return notificationUdid_; +} + +void NotificationOperationInfo::SetNotificationUdid(const std::string& udid) +{ + notificationUdid_ = udid; +} + std::string NotificationOperationInfo::Dump() { return "NotificationOperationInfo{ " @@ -93,6 +113,7 @@ std::string NotificationOperationInfo::Dump() ", actionName = " + actionName_ + ", operationType = " + std::to_string(static_cast(operationType_)) + ", btnIndex = " + std::to_string(btnIndex_) + + ", jumpType = " + std::to_string(jumpType_) + " }"; } @@ -123,8 +144,18 @@ bool NotificationOperationInfo::Marshalling(Parcel &parcel) const return false; } - if (!parcel.WriteInt32(static_cast(btnIndex_))) { - ANS_LOGE("Failed to write operationType"); + if (!parcel.WriteInt32(btnIndex_)) { + ANS_LOGE("Failed to write btnIndex"); + return false; + } + + if (!parcel.WriteInt32(jumpType_)) { + ANS_LOGE("Failed to write jumpType"); + return false; + } + + if (!parcel.WriteString(notificationUdid_)) { + ANS_LOGE("Failed to write notificationUdid"); return false; } @@ -155,7 +186,14 @@ bool NotificationOperationInfo::ReadFromParcel(Parcel &parcel) operationType_ = static_cast(parcel.ReadInt32()); - btnIndex_ = static_cast(parcel.ReadInt32()); + btnIndex_ = parcel.ReadInt32(); + + jumpType_ = parcel.ReadInt32(); + + if (!parcel.ReadString(notificationUdid_)) { + ANS_LOGE("Failed to read notificationUdid"); + return false; + } return true; } diff --git a/frameworks/ans/test/unittest/ans_log_test.cpp b/frameworks/ans/test/unittest/ans_log_test.cpp index b8f485e9b..03b69f424 100644 --- a/frameworks/ans/test/unittest/ans_log_test.cpp +++ b/frameworks/ans/test/unittest/ans_log_test.cpp @@ -364,6 +364,9 @@ HWTEST_F(AnsLogTest, AnsConvertTest_008, TestSize.Level1) inType = NotificationConstant::DISTRIBUTED_COLLABORATIVE_DELETE; NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType); EXPECT_EQ(outType, static_cast(NotificationNapi::RemoveReason::DISTRIBUTED_COLLABORATIVE_DELETE)); + inType = NotificationConstant::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE; + NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType); + EXPECT_EQ(outType, static_cast(NotificationNapi::RemoveReason::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE)); inType = NotificationConstant::APP_CANCEL_REASON_OTHER; NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType); EXPECT_EQ(outType, static_cast(NotificationNapi::RemoveReason::APP_CANCEL_REASON_OTHER)); diff --git a/frameworks/ans/test/unittest/notification_operation_info_test.cpp b/frameworks/ans/test/unittest/notification_operation_info_test.cpp index 76e3d86c9..4d4ddfc0b 100644 --- a/frameworks/ans/test/unittest/notification_operation_info_test.cpp +++ b/frameworks/ans/test/unittest/notification_operation_info_test.cpp @@ -32,6 +32,19 @@ public: void TearDown() {} }; +/** + * @tc.name: SetJumpType_0100 + * @tc.desc: Test SetJumpType. + * @tc.type: FUNC + * @tc.require: issueI5WBBH + */ +HWTEST_F(NotificationOperationInfoTest, SetJumpType_0100, Function | SmallTest | Level1) +{ + NotificationOperationInfo notificationOperationInfo; + notificationOperationInfo.SetJumpType(1); + EXPECT_EQ(notificationOperationInfo.GetJumpType(), 1); +} + /** * @tc.name: SetBtnIndex_0100 * @tc.desc: Test SetBtnIndex. @@ -55,11 +68,12 @@ HWTEST_F(NotificationOperationInfoTest, Dump_0100, Function | SmallTest | Level1 { NotificationOperationInfo notificationOperationInfo; std::string expString = "NotificationOperationInfo{ hashCode = hashCode, eventId = 1, actionName = actionName, " \ - "operationType = 0, btnIndex = 2 }"; + "operationType = 0, btnIndex = 2, jumpType = 1 }"; notificationOperationInfo.SetHashCode("hashCode"); notificationOperationInfo.SetEventId("1"); notificationOperationInfo.SetActionName("actionName"); notificationOperationInfo.SetOperationType(OperationType::DISTRIBUTE_OPERATION_JUMP); + notificationOperationInfo.SetJumpType(1); notificationOperationInfo.SetBtnIndex(2); EXPECT_EQ(notificationOperationInfo.Dump(), expString); } @@ -79,10 +93,14 @@ HWTEST_F(NotificationOperationInfoTest, Marshalling_0100, Function | SmallTest | notificationOperationInfo.SetActionName("actionName"); notificationOperationInfo.SetOperationType(OperationType::DISTRIBUTE_OPERATION_JUMP); notificationOperationInfo.SetBtnIndex(2); + notificationOperationInfo.SetJumpType(1); + notificationOperationInfo.SetNotificationUdid("udid"); EXPECT_TRUE(notificationOperationInfo.Marshalling(parcel)); NotificationOperationInfo ntfOperInfoRes; EXPECT_TRUE(ntfOperInfoRes.ReadFromParcel(parcel)); EXPECT_EQ(ntfOperInfoRes.GetBtnIndex(), 2); + EXPECT_EQ(ntfOperInfoRes.GetJumpType(), 1); + EXPECT_EQ(ntfOperInfoRes.GetNotificationUdid(), "udid"); } } } \ No newline at end of file diff --git a/frameworks/core/common/include/ans_convert_enum.h b/frameworks/core/common/include/ans_convert_enum.h index 5ecdbd870..cccbb6a1a 100644 --- a/frameworks/core/common/include/ans_convert_enum.h +++ b/frameworks/core/common/include/ans_convert_enum.h @@ -88,8 +88,9 @@ enum class RemoveReason { DISABLE_NOTIFICATION_FEATURE_REASON_DELETE = 31, DISTRIBUTED_COLLABORATIVE_DELETE = 32, USER_LOGOUT_REASON_DELETE = 33, - DISTRIBUTED_ENABLE_CLOSE_DELETE = 34, - DISTRIBUTED_RELEASE_DELETE = 35, + DISTRIBUTED_COLLABORATIVE_CLICK_DELETE = 34, + DISTRIBUTED_ENABLE_CLOSE_DELETE = 35, + DISTRIBUTED_RELEASE_DELETE = 36, APP_CANCEL_REASON_OTHER = 100, }; diff --git a/frameworks/core/common/src/ans_convert_enum.cpp b/frameworks/core/common/src/ans_convert_enum.cpp index 0d3994bb7..0b8a97834 100644 --- a/frameworks/core/common/src/ans_convert_enum.cpp +++ b/frameworks/core/common/src/ans_convert_enum.cpp @@ -285,6 +285,9 @@ bool AnsEnumUtil::ReasonCToJS(const int &inType, int &outType) case NotificationConstant::USER_LOGOUT_REASON_DELETE: outType = static_cast(RemoveReason::USER_LOGOUT_REASON_DELETE); break; + case NotificationConstant::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE: + outType = static_cast(RemoveReason::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE); + break; case NotificationConstant::DISTRIBUTED_ENABLE_CLOSE_DELETE: outType = static_cast(RemoveReason::DISTRIBUTED_ENABLE_CLOSE_DELETE); break; diff --git a/frameworks/js/napi/include/subscribe.h b/frameworks/js/napi/include/subscribe.h index 0934a80a7..648e4f996 100644 --- a/frameworks/js/napi/include/subscribe.h +++ b/frameworks/js/napi/include/subscribe.h @@ -16,6 +16,7 @@ #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_SUBSCRIBE_H #include "common.h" +#include "notification_constant.h" namespace OHOS { namespace NotificationNapi { @@ -211,7 +212,8 @@ struct AsyncCallbackInfoSubscribe { }; struct OperationInfo { - int32_t operationType; + bool withOperationInfo = false; + int32_t operationType = NotificationConstant::DISTRIBUTE_JUMP_INVALID; std::string actionName; std::string userInput; int32_t btnIndex; diff --git a/frameworks/js/napi/src/subscribe.cpp b/frameworks/js/napi/src/subscribe.cpp index 00d4688fa..0052d8990 100644 --- a/frameworks/js/napi/src/subscribe.cpp +++ b/frameworks/js/napi/src/subscribe.cpp @@ -1741,6 +1741,7 @@ napi_value GetParamOperationInfoSub(const napi_env &env, const napi_value &conte napi_value GetParamOperationInfo(const napi_env &env, const napi_value &content, OperationInfo& operationInfo) { + operationInfo.withOperationInfo = true; napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, content, &valuetype)); if (valuetype != napi_object) { @@ -1783,6 +1784,9 @@ napi_value GetParamOperationInfo(const napi_env &env, const napi_value &content, operationInfo.userInput = str; } + if (!operationInfo.userInput.empty()) { + return Common::NapiGetNull(env); + } return GetParamOperationInfoSub(env, content, operationInfo); } diff --git a/frameworks/js/napi/src/subscribe/napi_subscribe.cpp b/frameworks/js/napi/src/subscribe/napi_subscribe.cpp index 57c9a297a..561eb237f 100644 --- a/frameworks/js/napi/src/subscribe/napi_subscribe.cpp +++ b/frameworks/js/napi/src/subscribe/napi_subscribe.cpp @@ -45,21 +45,27 @@ void NapiDistributeOperationExecuteCallback(napi_env env, void *data) return; } operationInfo->SetHashCode(asyncCallbackInfo->hashCode); - if (asyncCallbackInfo->operationInfo.operationType == - static_cast(OperationType::DISTRIBUTE_OPERATION_REPLY)) { + if (asyncCallbackInfo->operationInfo.operationType == NotificationConstant::DISTRIBUTE_JUMP_INVALID && + asyncCallbackInfo->operationInfo.withOperationInfo) { operationInfo->SetOperationType(OperationType::DISTRIBUTE_OPERATION_REPLY); - operationInfo->SetBtnIndex(asyncCallbackInfo->operationInfo.btnIndex); operationInfo->SetActionName(asyncCallbackInfo->operationInfo.actionName); operationInfo->SetUserInput(asyncCallbackInfo->operationInfo.userInput); - } else if (asyncCallbackInfo->operationInfo.operationType < OperationType::DISTRIBUTE_OPERATION_FOR_LIVE_VIEW) { + } else if (asyncCallbackInfo->operationInfo.operationType == NotificationConstant::DISTRIBUTE_JUMP_INVALID) { operationInfo->SetOperationType(OperationType::DISTRIBUTE_OPERATION_JUMP); + } else if (asyncCallbackInfo->operationInfo.operationType >= NotificationConstant::DISTRIBUTE_JUMP_BY_LIVE_VIEW || + asyncCallbackInfo->operationInfo.operationType == NotificationConstant::DISTRIBUTE_JUMP_BY_NTF || + asyncCallbackInfo->operationInfo.operationType == NotificationConstant::DISTRIBUTE_JUMP_BY_BTN) { + operationInfo->SetOperationType(OperationType::DISTRIBUTE_OPERATION_JUMP_BY_TYPE); + operationInfo->SetJumpType(asyncCallbackInfo->operationInfo.operationType); + operationInfo->SetBtnIndex(asyncCallbackInfo->operationInfo.btnIndex); } else { - operationInfo->SetOperationType(static_cast(asyncCallbackInfo->operationInfo.operationType)); + ANS_LOGE("invalid param, operationType: %{public}d", asyncCallbackInfo->operationInfo.operationType); + callback->OnOperationCallback(ERR_ANS_INVALID_PARAM); + return; } int32_t result = NotificationHelper::DistributeOperation(operationInfo, callback); if (result != ERR_OK || - asyncCallbackInfo->operationInfo.operationType == - static_cast(OperationType::DISTRIBUTE_OPERATION_JUMP)) { + operationInfo->GetOperationType() != OperationType::DISTRIBUTE_OPERATION_REPLY) { callback->OnOperationCallback(result); } } diff --git a/interfaces/inner_api/notification_constant.h b/interfaces/inner_api/notification_constant.h index 5b45966be..841b0352f 100644 --- a/interfaces/inner_api/notification_constant.h +++ b/interfaces/inner_api/notification_constant.h @@ -407,7 +407,15 @@ public: static constexpr int32_t ANS_UID = 5523; - static constexpr int32_t MAX_BTN_NUM = 3; + static const int32_t MAX_BTN_NUM = 3; + + static const int32_t DISTRIBUTE_JUMP_INVALID = -1; + + static const int32_t DISTRIBUTE_JUMP_BY_NTF = 0; + + static const int32_t DISTRIBUTE_JUMP_BY_BTN = 1; + + static const int32_t DISTRIBUTE_JUMP_BY_LIVE_VIEW = 32; // live view max size is 512KB(extra size) + 8KB(base size) = 520KB static constexpr uint64_t NOTIFICATION_MAX_LIVE_VIEW_SIZE = 520ULL * 1024ULL; diff --git a/interfaces/inner_api/notification_operation_info.h b/interfaces/inner_api/notification_operation_info.h index 660e70237..426ff9ae2 100644 --- a/interfaces/inner_api/notification_operation_info.h +++ b/interfaces/inner_api/notification_operation_info.h @@ -26,7 +26,7 @@ namespace Notification { enum OperationType { DISTRIBUTE_OPERATION_JUMP = 0, DISTRIBUTE_OPERATION_REPLY, - DISTRIBUTE_OPERATION_FOR_LIVE_VIEW = 32 + DISTRIBUTE_OPERATION_JUMP_BY_TYPE }; class NotificationOperationInfo : public Parcelable { @@ -67,7 +67,15 @@ public: int32_t GetBtnIndex() const; - void SetBtnIndex(const int32_t& btnIndex); + void SetBtnIndex(const int32_t btnIndex); + + int32_t GetJumpType() const; + + void SetJumpType(const int32_t jumpType); + + std::string GetNotificationUdid() const; + + void SetNotificationUdid(const std::string& udid); std::string Dump(); @@ -96,6 +104,8 @@ private: std::string hashCode_; std::string eventId_; int32_t btnIndex_; + int32_t jumpType_; + std::string notificationUdid_; OperationType operationType_; }; } // namespace Notification diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 65e31518c..a30ec548c 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -1742,6 +1742,7 @@ private: ErrCode CheckNotificationRequest(const sptr &request); ErrCode CheckNotificationRequestLineWantAgents(const std::shared_ptr &content, bool isAgentController, bool isSystemComp); + bool IsReasonClickDelete(const int32_t removeReason); private: static sptr instance_; diff --git a/services/ans/include/notification_preferences.h b/services/ans/include/notification_preferences.h index 3154f43b7..eb5b61608 100644 --- a/services/ans/include/notification_preferences.h +++ b/services/ans/include/notification_preferences.h @@ -406,24 +406,24 @@ public: * * @param deviceType Type of the target device whose status you want to set. * @param deviceId The id of the target device. - * @param userId The userid of the target device. + * @param targetUserId The userid of the target device. * @param isAuth Return The authorization status. * @return Returns get result. */ ErrCode GetDistributedAuthStatus( - const std::string &deviceType, const std::string &deviceId, int32_t userId, bool &isAuth); + const std::string &deviceType, const std::string &deviceId, int32_t targetUserId, bool &isAuth); /** * @brief Set the target device's authorization status. * * @param deviceType Type of the target device whose status you want to set. * @param deviceId The id of the target device. - * @param userId The userid of the target device. + * @param targetUserId The userid of the target device. * @param isAuth The authorization status. * @return Returns set result. */ ErrCode SetDistributedAuthStatus( - const std::string &deviceType, const std::string &deviceId, int32_t userId, bool isAuth); + const std::string &deviceType, const std::string &deviceId, int32_t targetUserId, bool isAuth); /** * @brief Set the channel switch for collaborative reminders. diff --git a/services/ans/include/notification_preferences_database.h b/services/ans/include/notification_preferences_database.h index c741f232a..ba947e5dc 100644 --- a/services/ans/include/notification_preferences_database.h +++ b/services/ans/include/notification_preferences_database.h @@ -153,24 +153,24 @@ public: * * @param deviceType Type of the target device whose status you want to set. * @param deviceId The id of the target device. - * @param userId The userid of the target device. + * @param targetUserId The userid of the target device. * @param isAuth Return The authorization status. * @return Returns get result. */ - ErrCode GetDistributedAuthStatus( - const std::string &deviceType, const std::string &deviceId, int32_t userId, bool &isAuth); + bool GetDistributedAuthStatus( + const std::string &deviceType, const std::string &deviceId, int32_t targetUserId, bool &isAuth); /** * @brief Set the target device's authorization status. * * @param deviceType Type of the target device whose status you want to set. * @param deviceId The id of the target device. - * @param userId The userid of the target device. + * @param targetUserId The userid of the target device. * @param isAuth The authorization status. * @return Returns set result. */ - ErrCode SetDistributedAuthStatus( - const std::string &deviceType, const std::string &deviceId, int32_t userId, bool isAuth); + bool SetDistributedAuthStatus( + const std::string &deviceType, const std::string &deviceId, int32_t targetUserId, bool isAuth); /** * @brief Put smart reminder enable notification in the of bundle into disturbe DB. diff --git a/services/ans/include/notification_subscriber_manager.h b/services/ans/include/notification_subscriber_manager.h index d43ecdd64..b6b600fe7 100644 --- a/services/ans/include/notification_subscriber_manager.h +++ b/services/ans/include/notification_subscriber_manager.h @@ -132,9 +132,14 @@ public: /** * @brief Distribution operation based on hashCode. * - * @param notification Indicates the Notification object. + * @param operationInfo Indicates the Notification params. + * @param request Indicates the Notification request. */ - ErrCode DistributeOperation(const sptr& operationInfo); + ErrCode DistributeOperation( + const sptr& operationInfo, const sptr& request); + + ErrCode DistributeOperationTask(const sptr& operationInfo, + const sptr& request, int32_t &funcResult); void RegisterOnSubscriberAddCallback(std::function &)> callback); diff --git a/services/ans/src/advanced_notification_manager/advanced_notification_cancel.cpp b/services/ans/src/advanced_notification_manager/advanced_notification_cancel.cpp index a1946d744..b1d875f1c 100644 --- a/services/ans/src/advanced_notification_manager/advanced_notification_cancel.cpp +++ b/services/ans/src/advanced_notification_manager/advanced_notification_cancel.cpp @@ -382,7 +382,7 @@ ErrCode AdvancedNotificationService::ExcuteRemoveNotification(const sptrrequest; isThirdParty = record->isThirdparty; - if (removeReason != NotificationConstant::CLICK_REASON_DELETE) { + if (!IsReasonClickDelete(removeReason)) { ProcForDeleteLiveView(record); } @@ -400,12 +400,18 @@ ErrCode AdvancedNotificationService::ExcuteRemoveNotification(const sptr &bundleOption) { diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 48880e37b..4bdb38e2a 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1389,7 +1389,8 @@ ErrCode AdvancedNotificationService::RemoveFromNotificationList( } notification = record->notification; // delete or delete all, call the function - if (removeReason != NotificationConstant::CLICK_REASON_DELETE) { + if (removeReason != NotificationConstant::CLICK_REASON_DELETE && + removeReason != NotificationConstant::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE) { ProcForDeleteLiveView(record); if (!isCancel) { TriggerRemoveWantAgent(record->request, removeReason, record->isThirdparty); diff --git a/services/ans/src/distributed_manager/advanced_notification_distributed_manager_service.cpp b/services/ans/src/distributed_manager/advanced_notification_distributed_manager_service.cpp index 812f4c147..a1310978b 100644 --- a/services/ans/src/distributed_manager/advanced_notification_distributed_manager_service.cpp +++ b/services/ans/src/distributed_manager/advanced_notification_distributed_manager_service.cpp @@ -333,7 +333,7 @@ ErrCode DistributeOperationParamCheck(const sptr& ope OperationType operationType = operationInfo->GetOperationType(); if (operationType != OperationType::DISTRIBUTE_OPERATION_JUMP && operationType != OperationType::DISTRIBUTE_OPERATION_REPLY && - operationType < OperationType::DISTRIBUTE_OPERATION_FOR_LIVE_VIEW) { + operationType != OperationType::DISTRIBUTE_OPERATION_JUMP_BY_TYPE) { ANS_LOGE("operation type is error."); return ERR_ANS_INVALID_PARAM; } @@ -385,7 +385,7 @@ ErrCode AdvancedNotificationService::DistributeOperation(const sptrDistributeOperation(operationInfo); + result = NotificationSubscriberManager::GetInstance()->DistributeOperation(operationInfo, request); return; } ANS_LOGI("DistributeOperation not exist hashcode."); diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index 4b01f5898..50cc1f450 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -1178,22 +1178,22 @@ ErrCode NotificationPreferences::IsDistributedEnabled( } ErrCode NotificationPreferences::GetDistributedAuthStatus( - const std::string &deviceType, const std::string &deviceId, int32_t userId, bool &isAuth) + const std::string &deviceType, const std::string &deviceId, int32_t targetUserId, bool &isAuth) { ANS_LOGD("%{public}s", __FUNCTION__); std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; - storeDBResult = preferncesDB_->GetDistributedAuthStatus(deviceType, deviceId, userId, isAuth); + storeDBResult = preferncesDB_->GetDistributedAuthStatus(deviceType, deviceId, targetUserId, isAuth); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; } ErrCode NotificationPreferences::SetDistributedAuthStatus( - const std::string &deviceType, const std::string &deviceId, int32_t userId, bool isAuth) + const std::string &deviceType, const std::string &deviceId, int32_t targetUserId, bool isAuth) { ANS_LOGD("%{public}s", __FUNCTION__); std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; - storeDBResult = preferncesDB_->SetDistributedAuthStatus(deviceType, deviceId, userId, isAuth); + storeDBResult = preferncesDB_->SetDistributedAuthStatus(deviceType, deviceId, targetUserId, isAuth); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; } diff --git a/services/ans/src/notification_preferences_database.cpp b/services/ans/src/notification_preferences_database.cpp index 7f27a8788..5be0b27ac 100644 --- a/services/ans/src/notification_preferences_database.cpp +++ b/services/ans/src/notification_preferences_database.cpp @@ -2216,12 +2216,18 @@ bool NotificationPreferencesDatabase::GetDistributedEnabled( return result; } -ErrCode NotificationPreferencesDatabase::GetDistributedAuthStatus( - const std::string &deviceType, const std::string &deviceId, int32_t userId, bool &isAuth) +bool NotificationPreferencesDatabase::GetDistributedAuthStatus( + const std::string &deviceType, const std::string &deviceId, int32_t targetUserId, bool &isAuth) { - ANS_LOGD("%{public}s, deviceType: %{public}s, deviceId: %{public}s, userId: %{public}d", - __FUNCTION__, deviceType.c_str(), deviceId.c_str(), userId); - std::string key = GenerateBundleLablel(deviceType, deviceId, userId); + int32_t userId = SUBSCRIBE_USER_INIT; + OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(userId); + if (userId == SUBSCRIBE_USER_INIT) { + ANS_LOGE("Current user acquisition failed"); + return false; + } + ANS_LOGD("%{public}s, deviceType: %{public}s, deviceId: %{public}s, targetUserId: %{public}d", + __FUNCTION__, deviceType.c_str(), deviceId.c_str(), targetUserId); + std::string key = GenerateBundleLablel(deviceType, deviceId, targetUserId); bool result = false; isAuth = false; GetValueFromDisturbeDB(key, userId, [&](const int32_t &status, std::string &value) { @@ -2299,12 +2305,18 @@ bool NotificationPreferencesDatabase::IsSilentReminderEnabled( return result; } -ErrCode NotificationPreferencesDatabase::SetDistributedAuthStatus( - const std::string &deviceType, const std::string &deviceId, int32_t userId, bool isAuth) +bool NotificationPreferencesDatabase::SetDistributedAuthStatus( + const std::string &deviceType, const std::string &deviceId, int32_t targetUserId, bool isAuth) { - ANS_LOGD("%{public}s, deviceType: %{public}s, deviceId: %{public}s, userId: %{public}d", - __FUNCTION__, deviceType.c_str(), deviceId.c_str(), userId); - std::string key = GenerateBundleLablel(deviceType, deviceId, userId); + int32_t userId = SUBSCRIBE_USER_INIT; + OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(userId); + if (userId == SUBSCRIBE_USER_INIT) { + ANS_LOGE("Current user acquisition failed"); + return false; + } + ANS_LOGD("%{public}s, deviceType: %{public}s, deviceId: %{public}s, targetUserId: %{public}d", + __FUNCTION__, deviceType.c_str(), deviceId.c_str(), targetUserId); + std::string key = GenerateBundleLablel(deviceType, deviceId, targetUserId); int32_t result = PutDataToDB(key, static_cast(isAuth), userId); ANS_LOGD("key: %{public}s, result: %{public}d", key.c_str(), result); return (result == NativeRdb::E_OK); diff --git a/services/ans/src/notification_subscriber_manager.cpp b/services/ans/src/notification_subscriber_manager.cpp index 892ea2137..b97ddb792 100644 --- a/services/ans/src/notification_subscriber_manager.cpp +++ b/services/ans/src/notification_subscriber_manager.cpp @@ -53,6 +53,8 @@ struct NotificationSubscriberManager::SubscriberRecord { const uint32_t FILTETYPE_IM = 1 << 0; const uint32_t FILTETYPE_QUICK_REPLY_IM = 2 << 0; +static const std::string EXTENDINFO_INFO_PRE = "notification_collaboration_"; +static const std::string EXTENDINFO_DEVICE_ID = "deviceId"; NotificationSubscriberManager::NotificationSubscriberManager() { @@ -958,7 +960,8 @@ void NotificationSubscriberManager::TrackCodeLog( } } -ErrCode NotificationSubscriberManager::DistributeOperation(const sptr& operationInfo) +ErrCode NotificationSubscriberManager::DistributeOperation( + const sptr& operationInfo, const sptr& request) { NOTIFICATION_HITRACE(HITRACE_TAG_NOTIFICATION); if (notificationSubQueue_ == nullptr || operationInfo == nullptr) { @@ -969,20 +972,33 @@ ErrCode NotificationSubscriberManager::DistributeOperation(const sptrsubmit_h(std::bind([&]() { - for (const auto& record : subscriberRecordList_) { - if (record == nullptr) { - continue; - } - if (record->needNotifyResponse && record->subscriber != nullptr) { - result = record->subscriber->OnOperationResponse(operationInfo, funcResult); - return; - } - result = ERR_ANS_DISTRIBUTED_OPERATION_FAILED; - } + result = DistributeOperationTask(operationInfo, request, funcResult); })); notificationSubQueue_->wait(handler); ANS_LOGI("Subscriber manager operation %{public}s %{public}d", operationInfo->GetHashCode().c_str(), result); return result; } + +ErrCode NotificationSubscriberManager::DistributeOperationTask(const sptr& operationInfo, + const sptr& request, int32_t &funcResult) +{ + ErrCode result = ERR_OK; + for (const auto& record : subscriberRecordList_) { + if (record == nullptr) { + continue; + } + if (record->needNotifyResponse && record->subscriber != nullptr) { + std::string notificationUdid = + request->GetExtendInfo()->GetStringParam(EXTENDINFO_INFO_PRE + EXTENDINFO_DEVICE_ID); + operationInfo->SetNotificationUdid(notificationUdid); + result = record->subscriber->OnOperationResponse(operationInfo, funcResult); + if (result == ERR_OK) { + return result; + } + } + result = ERR_ANS_DISTRIBUTED_OPERATION_FAILED; + } + return result; +} } // namespace Notification } // namespace OHOS diff --git a/services/ans/test/unittest/advanced_notification_service_test/advanced_notification_distributed_manager_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test/advanced_notification_distributed_manager_service_test.cpp index 52719436a..399281464 100644 --- a/services/ans/test/unittest/advanced_notification_service_test/advanced_notification_distributed_manager_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test/advanced_notification_distributed_manager_service_test.cpp @@ -187,7 +187,7 @@ HWTEST_F(AdvancedNotificationDistMgrServiceTest, DistributeOperationParamCheck_1 HWTEST_F(AdvancedNotificationDistMgrServiceTest, DistributeOperationParamCheck_200, Function | SmallTest | Level1) { sptr operationInfo = new (std::nothrow) NotificationOperationInfo(); - operationInfo->SetOperationType(static_cast(2)); + operationInfo->SetOperationType(static_cast(5)); sptr callback = nullptr; auto ret = advancedNotificationService_->DistributeOperation(operationInfo, callback); ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); diff --git a/services/ans/test/unittest/notification_subscriber_manager_test.cpp b/services/ans/test/unittest/notification_subscriber_manager_test.cpp index f39d7016d..0e3d74a8e 100644 --- a/services/ans/test/unittest/notification_subscriber_manager_test.cpp +++ b/services/ans/test/unittest/notification_subscriber_manager_test.cpp @@ -1026,7 +1026,8 @@ HWTEST_F(NotificationSubscriberManagerTest, DistributeOperation_001, Function | info->SetNeedNotifyResponse(true); ASSERT_EQ(notificationSubscriberManager.AddSubscriberInner(subscriber, info), (int)ERR_OK); - notificationSubscriberManager.DistributeOperation(operationInfo); + sptr request = new (std::nothrow) NotificationRequest(); + notificationSubscriberManager.DistributeOperation(operationInfo, request); std::this_thread::sleep_for(std::chrono::milliseconds(400)); isCallback = testAnsSubscriber->GetCallBack(); ASSERT_TRUE(isCallback); diff --git a/services/distributed/include/base/distributed_liveview_all_scenarios_extension_wrapper.h b/services/distributed/include/base/distributed_liveview_all_scenarios_extension_wrapper.h index 6feac5deb..31a057a57 100644 --- a/services/distributed/include/base/distributed_liveview_all_scenarios_extension_wrapper.h +++ b/services/distributed/include/base/distributed_liveview_all_scenarios_extension_wrapper.h @@ -38,27 +38,33 @@ public: int32_t actionType, const AAFwk::WantParams extraInfo); typedef ErrCode (*SUBSCRIBE_ALL_CONNECT)(); typedef ErrCode (*UNSUBSCRIBE_ALL_CONNECT)(); - typedef ErrCode (*LIVE_VIEW_MULTI_SCREEN_SYNC_OPER)( + typedef ErrCode (*DISTRIBUTED_LIVE_VIEW_OPERATION)( sptr &request, const int32_t operationType, const int32_t btnIndex); - typedef ErrCode (*RESTORE_COLLABORATION_WINDOW)(const std::string &networkId); + typedef int32_t (*RESTORE_COLLABORATION_WINDOW)(const std::string &networkId); + typedef ErrCode (*DISTRIBUTED_ANCO_NOTIFICATION_CLICK)( + const sptr &request, bool &triggerWantInner); ErrCode UpdateLiveviewDecodeContent(const sptr &request, std::vector &buffer, const std::string& deviceType); ErrCode TriggerPushWantAgent(const sptr &request, int32_t actionType, const AAFwk::WantParams extraInfo); ErrCode SubscribeAllConnect(); ErrCode UnSubscribeAllConnect(); - ErrCode LiveViewMultiScreenSyncOper( + ErrCode DistributedLiveViewOperation( sptr &request, const int32_t operationType, const int32_t btnIndex); + ErrCode DistributedAncoNotificationClick(const sptr &request, bool &triggerWantInner); int32_t RestoreCollaborationWindow(const std::string &networkId); private: + void InitDistributedCollaborateClick(); + void* ExtensionHandle_ = nullptr; SUBSCRIBE_ALL_CONNECT subscribeHandler_ = nullptr; UNSUBSCRIBE_ALL_CONNECT unSubscribeHandler_ = nullptr; TRIGGER_PUSH_WANT_AGENT triggerHandler_ = nullptr; UPDATE_LIVEVIEW_ENCODE_CONTENT updateLiveviewEncodeContent_ = nullptr; UPDATE_LIVEVIEW_DECODE_CONTENT updateLiveviewDecodeContent_ = nullptr; - LIVE_VIEW_MULTI_SCREEN_SYNC_OPER liveViewMultiScreenSyncOper_ = nullptr; + DISTRIBUTED_LIVE_VIEW_OPERATION distributedLiveViewOperation_ = nullptr; RESTORE_COLLABORATION_WINDOW restoreCollaborationWindow_ = nullptr; + DISTRIBUTED_ANCO_NOTIFICATION_CLICK distributedAncoNotificationClick_ = nullptr; }; #define DISTRIBUTED_LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER \ diff --git a/services/distributed/include/soft_bus/distributed_operation_service.h b/services/distributed/include/soft_bus/distributed_operation_service.h index ace513b30..107244adb 100644 --- a/services/distributed/include/soft_bus/distributed_operation_service.h +++ b/services/distributed/include/soft_bus/distributed_operation_service.h @@ -35,15 +35,13 @@ public: OperationType operationType, uint32_t result); int32_t TriggerReplyApplication(const std::string& hashCode, const NotificationResponseBox& responseBox); void TriggerJumpApplication(const std::string& hashCode); - void DealNonMultiScreenSyncOper(const std::string& hashCode, const int32_t operationType, - const int32_t matchType, const NotificationResponseBox &responseBox); - void DealMultiScreenSyncOper(const std::string& hashCode, const int32_t operationType, - const int32_t matchType, const NotificationResponseBox &responseBox); + void TriggerByOperationType( + const std::string& hashCode, const int32_t operationType, const NotificationResponseBox& responseBox); #else int32_t OnOperationResponse(const std::shared_ptr& operationInfo, const DistributedDeviceInfo& device); void ResponseOperationResult(const std::string& hashCode, const NotificationResponseBox& responseBox); - void LaunchProjectionApp(const DistributedDeviceInfo& device, const DistributedDeviceInfo& localDevice); + void LaunchProjectionApp(const DistributedDeviceInfo& peerDevice, const DistributedDeviceInfo& localDevice); #endif }; } diff --git a/services/distributed/include/soft_bus/distributed_unlock_listener_oper_service.h b/services/distributed/include/soft_bus/distributed_unlock_listener_oper_service.h index fbcc3d047..fa67c3cc3 100644 --- a/services/distributed/include/soft_bus/distributed_unlock_listener_oper_service.h +++ b/services/distributed/include/soft_bus/distributed_unlock_listener_oper_service.h @@ -65,25 +65,28 @@ private: class UnlockListenerOperService { public: static UnlockListenerOperService& GetInstance(); - void AddWantAgent(const std::string& hashCode, - const std::shared_ptr wantAgentPtr); + void AddDelayTask(const std::string& hashCode, const int32_t jumpType, const int32_t btnIndex); void ReplyOperationResponse(); void HandleOperationTimeOut(const std::string& hashCode); void RemoveOperationResponse(const std::string& hashCode); - ErrCode LaunchWantAgent(const std::shared_ptr wantAgentPtr); + void TriggerByJumpType(const std::string& hashCode, const int32_t jumpType, const int32_t btnIndex); private: UnlockListenerOperService(); ~UnlockListenerOperService() = default; int64_t GetCurrentTime(); + std::shared_ptr GetNtfWantAgentPtr(const std::string& hashCode); + ErrCode LaunchWantAgent(const std::shared_ptr wantAgentPtr); + ErrCode GetNtfBtnWantAgentPtr(const std::string& hashCode, + const int32_t btnIndex, std::shared_ptr& wantAgentPtr); private: std::mutex mapLock_; std::shared_ptr operationQueue_ = nullptr; std::vector hashCodeOrder_; std::map timerMap_; - std::map> wantAgentMap_; + std::map> delayTaskMap_; }; } // namespace OHOS } // namespace Notification diff --git a/services/distributed/include/tlv_box/request_box.h b/services/distributed/include/tlv_box/request_box.h index d64422b3d..83a777e77 100644 --- a/services/distributed/include/tlv_box/request_box.h +++ b/services/distributed/include/tlv_box/request_box.h @@ -59,7 +59,6 @@ public: bool SetDeviceId(const std::string& deviceId); bool SetActionButtonsLength(const int32_t length); bool SetActionButtonsTitle(const std::vector& buttonsTitle); - bool SetActionUserInputs(const std::vector& userInputs); #else bool GetNotificationHashCode(std::string& hasdCode) const; bool GetSlotType(int32_t& type) const; @@ -90,7 +89,6 @@ public: bool GetDeviceId(std::string& deviceId) const; bool GetActionButtonsLength(int32_t& length) const; bool GetActionButtonsTitle(std::vector& buttonsTitle) const; - bool GetActionUserInputs(std::vector& userInputs) const; #endif }; } // namespace Notification diff --git a/services/distributed/include/tlv_box/response_box.h b/services/distributed/include/tlv_box/response_box.h index c0ac131fc..62b53132d 100644 --- a/services/distributed/include/tlv_box/response_box.h +++ b/services/distributed/include/tlv_box/response_box.h @@ -33,11 +33,11 @@ public: bool SetActionName(const std::string& actionName); bool SetUserInput(const std::string& userInput); bool SetOperationType(int32_t type); - bool SetOperationBtnIndex(int32_t index); + bool SetOperationBtnIndex(const int32_t index); + bool SetOperationJumpType(const int32_t jumpType); bool SetMatchType(int32_t type); bool SetLocalDeviceId(const std::string& deviceId); bool SetResponseResult(int32_t result); - bool SetLocalDeviceType(const int32_t& deviceType); bool GetNotificationHashCode(std::string& hashCode) const; bool GetOperationEventId(std::string& eventId) const; @@ -45,10 +45,10 @@ public: bool GetUserInput(std::string& userInput) const; bool GetOperationType(int32_t& type) const; bool GetOperationBtnIndex(int32_t& index) const; + bool GetOperationJumpType(int32_t& jumpType) const; bool GetMatchType(int32_t& type) const; bool GetLocalDeviceId(std::string& deviceId) const; bool GetResponseResult(int32_t& result) const; - bool GetLocalDeviceType(int32_t& deviceType) const; }; } // namespace Notification } // namespace OHOS diff --git a/services/distributed/include/tlv_box/tlv_box.h b/services/distributed/include/tlv_box/tlv_box.h index 88fb1275c..33ecc9ced 100644 --- a/services/distributed/include/tlv_box/tlv_box.h +++ b/services/distributed/include/tlv_box/tlv_box.h @@ -83,8 +83,8 @@ enum TlvType : int32_t { CHECK_SUM = 1000, OPERATION_BTN_INDEX = 1001, ACTION_BUTTONS_TITILE_INDEX = 1002, - ACTION_USER_INPUTS = 1005, - ACTION_BUTTONS_LENGTH = 1008, + ACTION_BUTTONS_LENGTH = 1005, + OPERATION_JUMP_TYPE = 1006, NOTIFICATION_ALL_LINES_START_INDEX = 2000, }; diff --git a/services/distributed/src/base/distributed_liveview_all_scenarios_extension_wrapper.cpp b/services/distributed/src/base/distributed_liveview_all_scenarios_extension_wrapper.cpp index 599a7800f..83b18e466 100644 --- a/services/distributed/src/base/distributed_liveview_all_scenarios_extension_wrapper.cpp +++ b/services/distributed/src/base/distributed_liveview_all_scenarios_extension_wrapper.cpp @@ -70,10 +70,16 @@ void DistributedLiveviewAllScenariosExtensionWrapper::InitExtentionWrapper() return; } - liveViewMultiScreenSyncOper_ = - (LIVE_VIEW_MULTI_SCREEN_SYNC_OPER)dlsym(ExtensionHandle_, "LiveViewMultiScreenSyncOper"); - if (liveViewMultiScreenSyncOper_ == nullptr) { - ANS_LOGE("distributed liveView multi-Screen sync failed, error: %{public}s", dlerror()); + InitDistributedCollaborateClick(); + ANS_LOGI("distributed liveview all scenarios extension wrapper init success"); +} + +void DistributedLiveviewAllScenariosExtensionWrapper::InitDistributedCollaborateClick() +{ + distributedLiveViewOperation_ = + (DISTRIBUTED_LIVE_VIEW_OPERATION)dlsym(ExtensionHandle_, "DistributedLiveViewOperation"); + if (distributedLiveViewOperation_ == nullptr) { + ANS_LOGE("distributed liveView operation failed, error: %{public}s", dlerror()); return; } @@ -83,7 +89,13 @@ void DistributedLiveviewAllScenariosExtensionWrapper::InitExtentionWrapper() ANS_LOGE("distributed restore collaboration window failed, error: %{public}s", dlerror()); return; } - ANS_LOGI("distributed liveview all scenarios extension wrapper init success"); + + distributedAncoNotificationClick_ = + (DISTRIBUTED_ANCO_NOTIFICATION_CLICK)dlsym(ExtensionHandle_, "DistributedAncoNotificationClick"); + if (distributedAncoNotificationClick_ == nullptr) { + ANS_LOGE("distributed anco notification click failed, error: %{public}s", dlerror()); + return; + } } void DistributedLiveviewAllScenariosExtensionWrapper::CloseExtentionWrapper() @@ -96,7 +108,7 @@ void DistributedLiveviewAllScenariosExtensionWrapper::CloseExtentionWrapper() triggerHandler_ = nullptr; updateLiveviewEncodeContent_ = nullptr; updateLiveviewDecodeContent_ = nullptr; - liveViewMultiScreenSyncOper_ = nullptr; + distributedLiveViewOperation_ = nullptr; restoreCollaborationWindow_ = nullptr; } ANS_LOGI("distributed liveview all scenarios extension wrapper close success"); @@ -150,14 +162,14 @@ ErrCode DistributedLiveviewAllScenariosExtensionWrapper::UnSubscribeAllConnect() return unSubscribeHandler_(); } -ErrCode DistributedLiveviewAllScenariosExtensionWrapper::LiveViewMultiScreenSyncOper( +ErrCode DistributedLiveviewAllScenariosExtensionWrapper::DistributedLiveViewOperation( sptr &request, const int32_t operationType, const int32_t btnIndex) { - if (liveViewMultiScreenSyncOper_ == nullptr) { - ANS_LOGE("liveView multi-Screen sync wrapper symbol failed"); + if (distributedLiveViewOperation_ == nullptr) { + ANS_LOGE("distributed liveView operation wrapper symbol failed"); return 0; } - return liveViewMultiScreenSyncOper_(request, operationType, btnIndex); + return distributedLiveViewOperation_(request, operationType, btnIndex); } int32_t DistributedLiveviewAllScenariosExtensionWrapper::RestoreCollaborationWindow(const std::string &networkId) @@ -168,4 +180,14 @@ int32_t DistributedLiveviewAllScenariosExtensionWrapper::RestoreCollaborationWin } return restoreCollaborationWindow_(networkId); } + +ErrCode DistributedLiveviewAllScenariosExtensionWrapper::DistributedAncoNotificationClick( + const sptr &request, bool &triggerWantInner) +{ + if (distributedAncoNotificationClick_ == nullptr) { + ANS_LOGE("distributed anco notification click wrapper symbol failed"); + return 0; + } + return distributedAncoNotificationClick_(request, triggerWantInner); +} } diff --git a/services/distributed/src/soft_bus/distributed_operation_service.cpp b/services/distributed/src/soft_bus/distributed_operation_service.cpp index 97fff6e4e..7e6f3b586 100644 --- a/services/distributed/src/soft_bus/distributed_operation_service.cpp +++ b/services/distributed/src/soft_bus/distributed_operation_service.cpp @@ -47,23 +47,32 @@ DistributedOperationService& DistributedOperationService::GetInstance() void DistributedOperationService::HandleNotificationOperation(const std::shared_ptr& boxMessage) { int32_t operationType = 0; + int32_t jumpType = 0; int32_t matchType = 0; int32_t peerDeviceType = DistributedHardware::DmDeviceType::DEVICE_TYPE_WATCH; std::string hashCode; NotificationResponseBox responseBox = NotificationResponseBox(boxMessage); responseBox.GetOperationType(operationType); + responseBox.GetOperationJumpType(jumpType); responseBox.GetMatchType(matchType); responseBox.GetNotificationHashCode(hashCode); - responseBox.GetLocalDeviceType(peerDeviceType); - ANS_LOGI("handle response, hashCode: %{public}s, operationType: %{public}d, matchType: %{public}d \ - peerDeviceType: %{public}d.", hashCode.c_str(), operationType, matchType, peerDeviceType); + ANS_LOGI("handle response, hashCode: %{public}s, operationType: %{public}d, matchType: %{public}d, \ + jumpType: %{public}d.", hashCode.c_str(), operationType, matchType, jumpType); #ifdef DISTRIBUTED_FEATURE_MASTER - if (peerDeviceType != DistributedHardware::DmDeviceType::DEVICE_TYPE_PAD && - peerDeviceType != DistributedHardware::DmDeviceType::DEVICE_TYPE_PC) { - DealNonMultiScreenSyncOper(hashCode, operationType, matchType, responseBox); + if (matchType != MatchType::MATCH_SYN) { return; } - DealMultiScreenSyncOper(hashCode, operationType, matchType, responseBox); + if (static_cast(operationType) == DISTRIBUTE_OPERATION_JUMP_BY_TYPE) { + int32_t btnIndex; + responseBox.GetOperationBtnIndex(btnIndex); + if (!ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked()) { + UnlockListenerOperService::GetInstance().TriggerByJumpType(hashCode, jumpType, btnIndex); + return; + } + UnlockListenerOperService::GetInstance().AddDelayTask(hashCode, jumpType, btnIndex); + return; + } + TriggerByOperationType(hashCode, operationType, responseBox); #else if (matchType == MatchType::MATCH_ACK) { ResponseOperationResult(hashCode, responseBox); @@ -147,47 +156,6 @@ static ErrCode GetNotificationButtonWantPtr(const std::string& hashCode, const s return ERR_OK; } -static ErrCode GetNotificationButtonWantAgentPtr(const std::string& hashCode, - const int32_t btnIndex, std::shared_ptr& wantAgentPtr) -{ - sptr notificationRequest = nullptr; - auto result = NotificationHelper::GetNotificationRequestByHashCode(hashCode, notificationRequest); - if (result != ERR_OK || notificationRequest == nullptr) { - ANS_LOGE("Check notificationRequest is null."); - return ERR_ANS_NOTIFICATION_NOT_EXISTS; - } - - auto actionButtons = notificationRequest->GetActionButtons(); - if (actionButtons.empty() || actionButtons.size() <= static_cast(btnIndex)) { - ANS_LOGE("Check actionButtons is null."); - return ERR_ANS_INVALID_PARAM; - } - - auto clickedBtn = actionButtons[btnIndex]; - if (clickedBtn == nullptr) { - ANS_LOGE("NotificationRequest button is invalid, btnIndex: %{public}d.", btnIndex); - return ERR_ANS_INVALID_PARAM; - } - - wantAgentPtr = clickedBtn->GetWantAgent(); - if (wantAgentPtr == nullptr) { - ANS_LOGE("Check wantAgentPtr is null."); - return ERR_ANS_INVALID_PARAM; - } - return ERR_OK; -} - -static std::shared_ptr GetNotificationWantAgentPtr(const std::string& hashCode) -{ - sptr notificationRequest = nullptr; - auto result = NotificationHelper::GetNotificationRequestByHashCode(hashCode, notificationRequest); - if (result != ERR_OK || notificationRequest == nullptr) { - ANS_LOGE("Check notificationRequest is null."); - return nullptr; - } - return notificationRequest->GetWantAgent(); -} - static std::shared_ptr GetNotificationWantPtr(const std::string& hashCode) { sptr notificationRequest = nullptr; @@ -330,12 +298,9 @@ void DistributedOperationService::TriggerJumpApplication(const std::string& hash } } -void DistributedOperationService::DealNonMultiScreenSyncOper(const std::string& hashCode, - const int32_t operationType, const int32_t matchType, const NotificationResponseBox &responseBox) +void DistributedOperationService::TriggerByOperationType( + const std::string& hashCode, const int32_t operationType, const NotificationResponseBox& responseBox) { - if (matchType != MatchType::MATCH_SYN) { - return; - } if (static_cast(operationType) == OperationType::DISTRIBUTE_OPERATION_JUMP) { TriggerJumpApplication(hashCode); } else if (static_cast(operationType) == OperationType::DISTRIBUTE_OPERATION_REPLY) { @@ -343,53 +308,6 @@ void DistributedOperationService::DealNonMultiScreenSyncOper(const std::string& ReplyOperationResponse(hashCode, responseBox, OperationType::DISTRIBUTE_OPERATION_REPLY, result); } } - -void DistributedOperationService::DealMultiScreenSyncOper(const std::string& hashCode, - const int32_t operationType, const int32_t matchType, const NotificationResponseBox &responseBox) -{ - if (matchType != MatchType::MATCH_SYN) { - return; - } - std::shared_ptr wantAgentPtr = nullptr; - if (operationType >= static_cast(OperationType::DISTRIBUTE_OPERATION_FOR_LIVE_VIEW)) { - sptr notificationRequest = nullptr; - auto result = NotificationHelper::GetNotificationRequestByHashCode(hashCode, notificationRequest); - if (result != ERR_OK || notificationRequest == nullptr) { - ANS_LOGE("Check notificationRequest is null."); - return; - } - if (!notificationRequest->IsCommonLiveView()) { - ANS_LOGE("operationType for liveView but notification not liveView."); - return; - } - int32_t btnIndex; - responseBox.GetOperationBtnIndex(btnIndex); - ErrCode res = DISTRIBUTED_LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->LiveViewMultiScreenSyncOper( - notificationRequest, operationType, btnIndex); - ANS_LOGI("LiveViewMultiScreenSyncOper res: %{public}d.", static_cast(res)); - return; - } else if (static_cast(operationType) == OperationType::DISTRIBUTE_OPERATION_JUMP) { - wantAgentPtr = GetNotificationWantAgentPtr(hashCode); - } else if (static_cast(operationType) == OperationType::DISTRIBUTE_OPERATION_REPLY) { - int32_t btnIndex; - responseBox.GetOperationBtnIndex(btnIndex); - GetNotificationButtonWantAgentPtr(hashCode, btnIndex, wantAgentPtr); - } - - if (wantAgentPtr == nullptr) { - ANS_LOGE("DealMultiScreenSyncOper fail cause wantAgentPtr is null."); - return; - } - if (!ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked() && - UnlockListenerOperService::GetInstance().LaunchWantAgent(wantAgentPtr) == ERR_OK) { - std::vector hashcodes; - hashcodes.push_back(hashCode); - NotificationHelper::RemoveNotifications( - hashcodes, NotificationConstant::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE); - return; - } - UnlockListenerOperService::GetInstance().AddWantAgent(hashCode, wantAgentPtr); -} #else int32_t DistributedOperationService::OnOperationResponse( @@ -411,21 +329,22 @@ int32_t DistributedOperationService::OnOperationResponse( ANS_LOGW("dans OnResponse SetMessageType failed"); return ERR_ANS_TASK_ERR; } - ANS_LOGI("dans OnResponse clicked btnIndex: %{public}d", operationInfo->GetBtnIndex()); - if (0 <= operationInfo->GetBtnIndex() && operationInfo->GetBtnIndex() < NotificationConstant::MAX_BTN_NUM) { - responseBox->SetOperationBtnIndex(operationInfo->GetBtnIndex()); - } responseBox->SetActionName(operationInfo->GetActionName()); responseBox->SetUserInput(operationInfo->GetUserInput()); } + if (type == OperationType::DISTRIBUTE_OPERATION_JUMP_BY_TYPE) { + responseBox->SetOperationJumpType(operationInfo->GetJumpType()); + if (operationInfo->GetBtnIndex() >= 0 && operationInfo->GetBtnIndex() < NotificationConstant::MAX_BTN_NUM) { + responseBox->SetOperationBtnIndex(operationInfo->GetBtnIndex()); + } + } auto localDevice = DistributedDeviceService::GetInstance().GetLocalDevice(); responseBox->SetMatchType(MatchType::MATCH_SYN); responseBox->SetOperationType(static_cast(type)); responseBox->SetNotificationHashCode(hashCode); responseBox->SetOperationEventId(operationInfo->GetEventId()); responseBox->SetLocalDeviceId(localDevice.deviceId_); - responseBox->SetLocalDeviceType(localDevice.deviceType_); if (!responseBox->Serialize()) { ANS_LOGW("dans OnResponse serialize failed"); return ERR_ANS_TASK_ERR; @@ -454,18 +373,18 @@ void DistributedOperationService::ResponseOperationResult(const std::string& has } void DistributedOperationService::LaunchProjectionApp( - const DistributedDeviceInfo& device, const DistributedDeviceInfo& localDevice) + const DistributedDeviceInfo& peerDevice, const DistributedDeviceInfo& localDevice) { if ((localDevice.deviceType_ != DistributedHardware::DmDeviceType::DEVICE_TYPE_PAD && localDevice.deviceType_ != DistributedHardware::DmDeviceType::DEVICE_TYPE_PC) || - device.deviceType_ != DistributedHardware::DmDeviceType::DEVICE_TYPE_PHONE) { + peerDevice.deviceType_ != DistributedHardware::DmDeviceType::DEVICE_TYPE_PHONE) { ANS_LOGI("Can not launch projectionApp"); return; } int32_t result = - DISTRIBUTED_LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->RestoreCollaborationWindow(device.networkId_); + DISTRIBUTED_LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->RestoreCollaborationWindow(peerDevice.networkId_); ANS_LOGI("RestoreCollaborationWindow result: %{public}d, networkId: %{public}s", - result, device.networkId_.c_str()); + result, peerDevice.networkId_.c_str()); } #endif } diff --git a/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp b/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp index 966adec56..da6a309e1 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp @@ -477,13 +477,10 @@ void DistributedPublishService::SetNotificationButtons(const sptrIsCommonLiveView()) { - return; - } + if ((deviceType == DistributedHardware::DmDeviceType::DEVICE_TYPE_PAD || + deviceType == DistributedHardware::DmDeviceType::DEVICE_TYPE_PC) && + !notificationRequest->IsCommonLiveView()) { std::vector buttonsTitle; - std::vector userInputs; size_t length = actionButtons.size(); if (length > NotificationConstant::MAX_BTN_NUM) { length = NotificationConstant::MAX_BTN_NUM; @@ -492,16 +489,13 @@ void DistributedPublishService::SetNotificationButtons(const sptrGetTitle()); - std::string inputKey = ""; if (actionButtons[i]->GetUserInput() != nullptr) { - userInputs.push_back(actionButtons[i]->GetUserInput()->GetInputKey()); - } else { - userInputs.push_back(inputKey); + ANS_LOGI("distributed override reply button."); + continue; } + buttonsTitle.push_back(actionButtons[i]->GetTitle()); } requestBox->SetActionButtonsTitle(buttonsTitle); - requestBox->SetActionUserInputs(userInputs); return; } if (slotType == NotificationConstant::SlotType::SOCIAL_COMMUNICATION) { @@ -687,27 +681,12 @@ void DistributedPublishService::MakePadNotificationButtons( return; } std::vector buttonsTitle; - std::vector userInputs; - if (!box.GetActionButtonsTitle(buttonsTitle) || - !box.GetActionUserInputs(userInputs) || buttonsTitle.size() <= 0) { - ANS_LOGI("Notification [hashCode: %{public}s] has no button.", request->GetNotificationHashCode().c_str()); - return; - } - if (buttonsTitle.size() != userInputs.size()) { - ANS_LOGE("Notification [hashCode: %{public}s] inner error, button property size not same.", - request->GetNotificationHashCode().c_str()); + if (!box.GetActionButtonsTitle(buttonsTitle) || buttonsTitle.size() <= 0) { return; } for (size_t i = 0; i < buttonsTitle.size(); i++) { std::shared_ptr actionButton = NotificationActionButton::Create(nullptr, buttonsTitle[i], nullptr); - std::shared_ptr userInput; - if (userInputs[i].length() > 0) { - userInput = NotificationUserInput::Create(userInputs[i]); - } - if (userInput) { - actionButton->AddNotificationUserInput(userInput); - } request->AddActionButton(actionButton); } } diff --git a/services/distributed/src/soft_bus/distributed_subscriber.cpp b/services/distributed/src/soft_bus/distributed_subscriber.cpp index 7bd3218f8..1aab8eacf 100644 --- a/services/distributed/src/soft_bus/distributed_subscriber.cpp +++ b/services/distributed/src/soft_bus/distributed_subscriber.cpp @@ -149,9 +149,14 @@ void DistribuedSubscriber::OnBatchCanceled(const std::vector &operationInfo) { - ANS_LOGI("Subscriber on response %{public}d %{public}s %{public}d %{public}s.", + DistributedDeviceInfo operRespDevice; + DistributedDeviceService::GetInstance().GetDeviceInfoByUdid(operationInfo->GetNotificationUdid(), operRespDevice); + ANS_LOGI("Subscriber on response %{public}d %{public}s %{public}d %{public}s, OperRespDeviceId: %{public}s.", peerDevice_.deviceType_, StringAnonymous(peerDevice_.deviceId_).c_str(), localDevice_.deviceType_, - StringAnonymous(localDevice_.deviceId_).c_str()); + StringAnonymous(localDevice_.deviceId_).c_str(), operRespDevice.deviceId_.c_str()); + if (operRespDevice.deviceId_.compare(peerDevice_.deviceId_) != 0) { + return ERR_ANS_DISTRIBUTED_OPERATION_FAILED; + } return DistributedService::GetInstance().OnOperationResponse(operationInfo, peerDevice_); } diff --git a/services/distributed/src/soft_bus/distributed_unlock_listener_oper_service.cpp b/services/distributed/src/soft_bus/distributed_unlock_listener_oper_service.cpp index 8bf7fff15..8f78c52b2 100644 --- a/services/distributed/src/soft_bus/distributed_unlock_listener_oper_service.cpp +++ b/services/distributed/src/soft_bus/distributed_unlock_listener_oper_service.cpp @@ -16,7 +16,9 @@ #ifdef DISTRIBUTED_FEATURE_MASTER #include "distributed_unlock_listener_oper_service.h" +#include "ans_inner_errors.h" #include "ans_log_wrapper.h" +#include "distributed_liveview_all_scenarios_extension_wrapper.h" #include "notification_constant.h" #include "notification_helper.h" #include "time_service_client.h" @@ -47,8 +49,8 @@ UnlockListenerOperService::UnlockListenerOperService() ANS_LOGI("Operation service init successfully."); } -void UnlockListenerOperService::AddWantAgent(const std::string& hashCode, - const std::shared_ptr wantAgentPtr) +void UnlockListenerOperService::AddDelayTask( + const std::string& hashCode, const int32_t jumpType, const int32_t btnIndex) { int32_t timeout = OPERATION_TIMEOUT; int64_t expiredTime = GetCurrentTime() + timeout; @@ -61,12 +63,12 @@ void UnlockListenerOperService::AddWantAgent(const std::string& hashCode, uint64_t timerId = timer->CreateTimer(timerInfo); timer->StartTimer(timerId, expiredTime); std::lock_guard lock(mapLock_); - auto iterWantAgent = wantAgentMap_.find(hashCode); - if (iterWantAgent != wantAgentMap_.end()) { - ANS_LOGW("Operation wantAgent has same key %{public}s.", hashCode.c_str()); - wantAgentMap_.erase(iterWantAgent); + auto iterDelayTask = delayTaskMap_.find(hashCode); + if (iterDelayTask != delayTaskMap_.end()) { + ANS_LOGW("Operation delayTask has same key %{public}s.", hashCode.c_str()); + delayTaskMap_.erase(iterDelayTask); } - wantAgentMap_.insert_or_assign(hashCode, wantAgentPtr); + delayTaskMap_.insert_or_assign(hashCode, std::make_pair(jumpType, btnIndex)); auto iterTimer = timerMap_.find(hashCode); if (iterTimer != timerMap_.end()) { @@ -90,9 +92,9 @@ void UnlockListenerOperService::AddWantAgent(const std::string& hashCode, void UnlockListenerOperService::RemoveOperationResponse(const std::string& hashCode) { std::lock_guard lock(mapLock_); - auto iterWantAgent = wantAgentMap_.find(hashCode); - if (iterWantAgent != wantAgentMap_.end()) { - wantAgentMap_.erase(iterWantAgent); + auto iterDelayTask = delayTaskMap_.find(hashCode); + if (iterDelayTask != delayTaskMap_.end()) { + delayTaskMap_.erase(iterDelayTask); ANS_LOGI("Operation wantAgent erase %{public}s", hashCode.c_str()); } @@ -116,14 +118,11 @@ void UnlockListenerOperService::ReplyOperationResponse() { std::lock_guard lock(mapLock_); ANS_LOGI("UnlockListenerOperService ReplyOperationResponse hashCodeOrder size %{public}u", hashCodeOrder_.size()); - std::vector hashcodesToDel; for (std::string hashCode : hashCodeOrder_) { - auto iterWantAgent = wantAgentMap_.find(hashCode); - if (iterWantAgent != wantAgentMap_.end()) { - if (LaunchWantAgent(iterWantAgent->second) == ERR_OK) { - hashcodesToDel.push_back(hashCode); - } - wantAgentMap_.erase(iterWantAgent); + auto iterDelayTask = delayTaskMap_.find(hashCode); + if (iterDelayTask != delayTaskMap_.end()) { + TriggerByJumpType(hashCode, iterDelayTask->second.first, iterDelayTask->second.second); + delayTaskMap_.erase(iterDelayTask); } auto iterTimer = timerMap_.find(hashCode); @@ -136,8 +135,6 @@ void UnlockListenerOperService::ReplyOperationResponse() timerMap_.erase(iterTimer); } } - NotificationHelper::RemoveNotifications( - hashcodesToDel, NotificationConstant::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE); hashCodeOrder_.clear(); } @@ -154,6 +151,113 @@ void UnlockListenerOperService::HandleOperationTimeOut(const std::string& hashCo }); } +void UnlockListenerOperService::TriggerByJumpType( + const std::string& hashCode, const int32_t jumpType, const int32_t btnIndex) +{ + sptr notificationRequest = nullptr; + auto result = NotificationHelper::GetNotificationRequestByHashCode(hashCode, notificationRequest); + if (result != ERR_OK || notificationRequest == nullptr) { + ANS_LOGE("Check notificationRequest is null."); + return; + } + std::shared_ptr wantAgentPtr = nullptr; + if (jumpType >= NotificationConstant::DISTRIBUTE_JUMP_BY_LIVE_VIEW) { + if (!notificationRequest->IsCommonLiveView()) { + ANS_LOGE("jumpType for liveView but notification not liveView."); + return; + } + ErrCode res = DISTRIBUTED_LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->DistributedLiveViewOperation( + notificationRequest, jumpType, btnIndex); + ANS_LOGI("DistributedLiveViewOperation res: %{public}d.", static_cast(res)); + return; + } + bool triggerWantInner; + ErrCode res = DISTRIBUTED_LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->DistributedAncoNotificationClick( + notificationRequest, triggerWantInner); + if (res != ERR_OK) { + return; + } + if (triggerWantInner && res == ERR_OK) { + std::vector hashcodes; + hashcodes.push_back(hashCode); + NotificationHelper::RemoveNotifications( + hashcodes, NotificationConstant::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE); + return; + } + if (jumpType == NotificationConstant::DISTRIBUTE_JUMP_BY_NTF) { + wantAgentPtr = GetNtfWantAgentPtr(hashCode); + } else if (jumpType == NotificationConstant::DISTRIBUTE_JUMP_BY_BTN) { + GetNtfBtnWantAgentPtr(hashCode, btnIndex, wantAgentPtr); + } + + if (wantAgentPtr == nullptr) { + ANS_LOGE("DealMultiScreenSyncOper fail cause wantAgentPtr is null."); + return; + } + if (LaunchWantAgent(wantAgentPtr) == ERR_OK) { + std::vector hashcodes; + hashcodes.push_back(hashCode); + NotificationHelper::RemoveNotifications( + hashcodes, NotificationConstant::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE); + } +} + +ErrCode UnlockListenerOperService::GetNtfBtnWantAgentPtr(const std::string& hashCode, + const int32_t btnIndex, std::shared_ptr& wantAgentPtr) +{ + sptr notificationRequest = nullptr; + auto result = NotificationHelper::GetNotificationRequestByHashCode(hashCode, notificationRequest); + if (result != ERR_OK || notificationRequest == nullptr) { + ANS_LOGE("Check notificationRequest is null."); + return ERR_ANS_NOTIFICATION_NOT_EXISTS; + } + + auto actionButtons = notificationRequest->GetActionButtons(); + if (actionButtons.empty() || actionButtons.size() <= static_cast(btnIndex) || btnIndex < 0) { + ANS_LOGE("Check actionButtons is null."); + return ERR_ANS_INVALID_PARAM; + } + + std::shared_ptr clickedBtn; + int32_t replyBtnNum = 0; + for (int i = 0; i < static_cast(actionButtons.size()) && + btnIndex + replyBtnNum < static_cast(actionButtons.size()); i++) { + if (actionButtons[i] == nullptr) { + ANS_LOGE("NotificationRequest button is invalid, button index: %{public}d.", i); + return ERR_ANS_INVALID_PARAM; + } + if (actionButtons[i]->GetUserInput() != nullptr) { + replyBtnNum++; + continue; + } + if (btnIndex + replyBtnNum == i) { + clickedBtn = actionButtons[i]; + } + } + if (clickedBtn == nullptr) { + ANS_LOGE("NotificationRequest btnIndex is invalid."); + return ERR_ANS_INVALID_PARAM; + } + wantAgentPtr = clickedBtn->GetWantAgent(); + if (wantAgentPtr == nullptr) { + ANS_LOGE("Check wantAgentPtr is null."); + return ERR_ANS_INVALID_PARAM; + } + return ERR_OK; +} + +std::shared_ptr UnlockListenerOperService::GetNtfWantAgentPtr( + const std::string& hashCode) +{ + sptr notificationRequest = nullptr; + auto result = NotificationHelper::GetNotificationRequestByHashCode(hashCode, notificationRequest); + if (result != ERR_OK || notificationRequest == nullptr) { + ANS_LOGE("Check notificationRequest is null."); + return nullptr; + } + return notificationRequest->GetWantAgent(); +} + ErrCode UnlockListenerOperService::LaunchWantAgent( const std::shared_ptr wantAgentPtr) { diff --git a/services/distributed/src/tlv_box/request_box.cpp b/services/distributed/src/tlv_box/request_box.cpp index 015c11b35..ef64c6eac 100644 --- a/services/distributed/src/tlv_box/request_box.cpp +++ b/services/distributed/src/tlv_box/request_box.cpp @@ -323,18 +323,6 @@ bool NotificationRequestBox::SetActionButtonsTitle(const std::vector& userInputs) -{ - if (box_ == nullptr) { - return false; - } - for (size_t i = 0; i < userInputs.size(); i++) { - box_->PutValue( - std::make_shared(ACTION_USER_INPUTS + i, userInputs[i])); - } - return true; -} - #else bool NotificationRequestBox::GetNotificationHashCode(std::string& hasdCode) const { @@ -598,23 +586,6 @@ bool NotificationRequestBox::GetActionButtonsTitle(std::vector& but } return true; } - -bool NotificationRequestBox::GetActionUserInputs(std::vector& userInputs) const -{ - if (box_ == nullptr) { - return false; - } - int32_t length = 0; - if (!GetActionButtonsLength(length)) { - return false; - } - for (int i = 0; i < length; i++) { - std::string userInput = ""; - box_->GetStringValue(ACTION_USER_INPUTS + i, userInput); - userInputs.push_back(userInput); - } - return true; -} #endif } } diff --git a/services/distributed/src/tlv_box/response_box.cpp b/services/distributed/src/tlv_box/response_box.cpp index 93d5fd34b..ee6b85301 100644 --- a/services/distributed/src/tlv_box/response_box.cpp +++ b/services/distributed/src/tlv_box/response_box.cpp @@ -76,7 +76,7 @@ bool NotificationResponseBox::SetOperationType(int32_t type) return box_->PutValue(std::make_shared(OPERATION_TYPE, type)); } -bool NotificationResponseBox::SetOperationBtnIndex(int32_t index) +bool NotificationResponseBox::SetOperationBtnIndex(const int32_t index) { if (box_ == nullptr) { return false; @@ -84,36 +84,36 @@ bool NotificationResponseBox::SetOperationBtnIndex(int32_t index) return box_->PutValue(std::make_shared(OPERATION_BTN_INDEX, index)); } -bool NotificationResponseBox::SetMatchType(int32_t type) +bool NotificationResponseBox::SetOperationJumpType(const int32_t jumpType) { if (box_ == nullptr) { return false; } - return box_->PutValue(std::make_shared(MATCH_TYPE, type)); + return box_->PutValue(std::make_shared(OPERATION_JUMP_TYPE, jumpType)); } -bool NotificationResponseBox::SetLocalDeviceId(const std::string& deviceId) +bool NotificationResponseBox::SetMatchType(int32_t type) { if (box_ == nullptr) { return false; } - return box_->PutValue(std::make_shared(LOCAL_DEVICE_ID, deviceId)); + return box_->PutValue(std::make_shared(MATCH_TYPE, type)); } -bool NotificationResponseBox::SetResponseResult(int32_t result) +bool NotificationResponseBox::SetLocalDeviceId(const std::string& deviceId) { if (box_ == nullptr) { return false; } - return box_->PutValue(std::make_shared(RESULT_CODE, result)); + return box_->PutValue(std::make_shared(LOCAL_DEVICE_ID, deviceId)); } -bool NotificationResponseBox::SetLocalDeviceType(const int32_t& deviceType) +bool NotificationResponseBox::SetResponseResult(int32_t result) { if (box_ == nullptr) { return false; } - return box_->PutValue(std::make_shared(LOCAL_DEVICE_TYPE, deviceType)); + return box_->PutValue(std::make_shared(RESULT_CODE, result)); } bool NotificationResponseBox::GetNotificationHashCode(std::string& hashCode) const @@ -164,36 +164,36 @@ bool NotificationResponseBox::GetOperationBtnIndex(int32_t& index) const return box_->GetInt32Value(OPERATION_BTN_INDEX, index); } -bool NotificationResponseBox::GetMatchType(int32_t& type) const +bool NotificationResponseBox::GetOperationJumpType(int32_t& jumpType) const { if (box_ == nullptr) { return false; } - return box_->GetInt32Value(MATCH_TYPE, type); + return box_->GetInt32Value(OPERATION_JUMP_TYPE, jumpType); } -bool NotificationResponseBox::GetLocalDeviceId(std::string& deviceId) const +bool NotificationResponseBox::GetMatchType(int32_t& type) const { if (box_ == nullptr) { return false; } - return box_->GetStringValue(LOCAL_DEVICE_ID, deviceId); + return box_->GetInt32Value(MATCH_TYPE, type); } -bool NotificationResponseBox::GetResponseResult(int32_t& result) const +bool NotificationResponseBox::GetLocalDeviceId(std::string& deviceId) const { if (box_ == nullptr) { return false; } - return box_->GetInt32Value(RESULT_CODE, result); + return box_->GetStringValue(LOCAL_DEVICE_ID, deviceId); } -bool NotificationResponseBox::GetLocalDeviceType(int32_t& deviceType) const +bool NotificationResponseBox::GetResponseResult(int32_t& result) const { if (box_ == nullptr) { return false; } - return box_->GetInt32Value(LOCAL_DEVICE_TYPE, deviceType); + return box_->GetInt32Value(RESULT_CODE, result); } } // namespace Notification } // namespace OHOS -- Gitee