diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 0bb45e4d6c66db7bb4453b9cc429ca39101fda83..e700b6d529c1fce65612882d25a9ab81af2624cb 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -170,6 +170,7 @@ DM_EXPORT extern const char* DM_VAL_TRUE; DM_EXPORT extern const char* DM_VAL_FALSE; DM_EXPORT extern const char* APP_USER_DATA; DM_EXPORT extern const char* BUNDLE_INFO; +DM_EXPORT extern const char* TITLE; DM_EXPORT extern const char* DM_BUSINESS_ID; // screen state diff --git a/common/src/dm_constants.cpp b/common/src/dm_constants.cpp index a3b82a7c088d9fa8cb0a5d0af8bf0e296651d47a..35e9ebc0e702c86c0da6ec6a3f69baf8b1a5f2e1 100644 --- a/common/src/dm_constants.cpp +++ b/common/src/dm_constants.cpp @@ -160,6 +160,7 @@ const char* DM_VAL_TRUE = "true"; const char* DM_VAL_FALSE = "false"; const char* APP_USER_DATA = "appUserData"; const char* BUNDLE_INFO = "bundleInfo"; +const char* TITLE = "title"; const char* DM_BUSINESS_ID = "business_id"; // errCode map diff --git a/services/implementation/include/ability/dm_dialog_manager.h b/services/implementation/include/ability/dm_dialog_manager.h index 9a0dfc958cf227fdf7146924866a96041b0d7d6e..73c92997c4d14e53501ac27b0fce80c467d53767 100644 --- a/services/implementation/include/ability/dm_dialog_manager.h +++ b/services/implementation/include/ability/dm_dialog_manager.h @@ -85,6 +85,10 @@ public: { return appUserData_; } + static std::string GetTitle() + { + return title_; + } private: DmDialogManager(); ~DmDialogManager(); @@ -112,6 +116,7 @@ private: static DmDialogManager dialogMgr_; static bool isProxyBind_; static std::string appUserData_; + static std::string title_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/include/authentication_v2/dm_auth_context.h b/services/implementation/include/authentication_v2/dm_auth_context.h index f4308c85632a16e02e86564d00c942787fe9cc7e..d2c1263324c77242629d5d5e311aec2e8281d6d8 100644 --- a/services/implementation/include/authentication_v2/dm_auth_context.h +++ b/services/implementation/include/authentication_v2/dm_auth_context.h @@ -278,6 +278,7 @@ struct DmAuthContext { bool isNeedAuthorize{false}; std::vector subjectProxyOnes; std::string reUseCreId; + std::string title; std::string srvExtarInfo; std::shared_ptr authStateMachine; diff --git a/services/implementation/include/authentication_v2/dm_auth_manager_base.h b/services/implementation/include/authentication_v2/dm_auth_manager_base.h index 01be5c0bdf4c0b3971cfa4a3f5dfd1f9d77c840a..2bb96eefebeb98b1f8cd2630dcf35952f35a030b 100644 --- a/services/implementation/include/authentication_v2/dm_auth_manager_base.h +++ b/services/implementation/include/authentication_v2/dm_auth_manager_base.h @@ -250,6 +250,7 @@ public: void DisableInsensibleSwitching(); int32_t ParseAuthType(const std::map &bindParam, int32_t &authType); static bool CheckProcessNameInWhiteList(const std::string &processName); + static bool CheckProcessNameInProxyAdaptationList(const std::string &processName); protected: bool NeedInsensibleSwitching(); bool isTransferReady_{true}; diff --git a/services/implementation/include/authentication_v2/dm_auth_state.h b/services/implementation/include/authentication_v2/dm_auth_state.h index cd7de24cb3ce05450732ad4291392c48378aeafa..b8bf3536d688f2a122aa85564269ce0c168acbb9 100644 --- a/services/implementation/include/authentication_v2/dm_auth_state.h +++ b/services/implementation/include/authentication_v2/dm_auth_state.h @@ -547,6 +547,7 @@ private: void GetSinkProxyCredTypeForP2P(std::shared_ptr context, std::vector &deleteCredInfo); bool IsAntiDisturbanceMode(const std::string &businessId); bool ParseAndCheckAntiDisturbanceMode(const std::string &businessId, const std::string &businessValue); + void SetIsProxyBind(std::shared_ptr context); }; class AuthSinkDataSyncState : public DmAuthState { diff --git a/services/implementation/src/ability/standard/dm_dialog_manager.cpp b/services/implementation/src/ability/standard/dm_dialog_manager.cpp index 5b93c3a29a30c57db82778bfe7faf09024997572..f3c788e30621f17d7cb992b7b6d6ecdc0aebc633 100644 --- a/services/implementation/src/ability/standard/dm_dialog_manager.cpp +++ b/services/implementation/src/ability/standard/dm_dialog_manager.cpp @@ -53,6 +53,7 @@ std::string DmDialogManager::hostPkgLabel_ = ""; int32_t DmDialogManager::deviceType_ = -1; bool DmDialogManager::isProxyBind_ = false; std::string DmDialogManager::appUserData_ = ""; +std::string DmDialogManager::title_ = ""; DmDialogManager DmDialogManager::dialogMgr_; sptr DmDialogManager::dialogConnectionCallback_( new (std::nothrow) DialogAbilityConnection()); @@ -105,6 +106,9 @@ void DmDialogManager::ShowConfirmDialog(const std::string param) if (IsString(jsonObject, APP_USER_DATA)) { appUserData_ = jsonObject[APP_USER_DATA].Get(); } + if (IsString(jsonObject, TITLE)) { + title_ = jsonObject[TITLE].Get(); + } } bundleName_ = DM_UI_BUNDLE_NAME; @@ -207,6 +211,7 @@ void DmDialogManager::DialogAbilityConnection::OnAbilityConnectDone( LOGI("OnAbilityConnectDone pinCodeHash: %{public}s", pinCodeHash.c_str()); param["isProxyBind"] = DmDialogManager::GetIsProxyBind(); param["appUserData"] = DmDialogManager::GetAppUserData(); + param["title"] = DmDialogManager::GetTitle(); param["pinCode"] = DmDialogManager::GetPinCode(); param["deviceName"] = DmDialogManager::GetDeviceName(); param["appOperationStr"] = DmDialogManager::GetAppOperationStr(); diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp index efd7b58c5e48a5f7187d4b8aa2f8bb46ccaf36e2..1e1c7b3c63a24ff149c7646e6bbfc41f25adea25 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp @@ -770,6 +770,7 @@ int32_t AuthSinkConfirmState::CreateProxyData(std::shared_ptr con allProxyObj.PushBack(object); } jsonObj[APP_USER_DATA] = allProxyObj.Dump(); + jsonObj[TITLE] = context->title; return DM_OK; } @@ -1118,6 +1119,9 @@ bool AuthSinkConfirmState::ProcessServerAuthorize(std::shared_ptr LOGE("no subject proxy data"); return false; } + if (IsString(jsonObj, TITLE)) { + context->title = jsonObj[TITLE].Get(); + } JsonObject appDataObj; std::string appDataStr = jsonObj[APP_USER_DATA].Dump(); appDataObj.Parse(appDataStr); diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp index 0faacf70203a2a2c461605fd4ba1b1180c71960f..7b3a1b607f2e39c1ff98f37f991c97203e52d632 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp @@ -241,6 +241,7 @@ int32_t AuthSinkNegotiateStateMachine::Action(std::shared_ptr con context->reason = ERR_DM_VERSION_INCOMPATIBLE; return ERR_DM_VERSION_INCOMPATIBLE; } + SetIsProxyBind(context); int32_t ret = ProcRespNegotiate5_1_0(context); if (ret != DM_OK) { LOGE("AuthSinkNegotiateStateMachine::Action proc response negotiate failed"); @@ -256,6 +257,43 @@ int32_t AuthSinkNegotiateStateMachine::Action(std::shared_ptr con return DM_OK; } +void AuthSinkNegotiateStateMachine::SetIsProxyBind(std::shared_ptr context) +{ + CHECK_NULL_VOID(context); + if (!context->IsProxyBind) { + return; + } + if (AuthManagerBase::CheckProcessNameInProxyAdaptationList(context->accessee.pkgName)) { + LOGI("%{public}s in proxy adaptation list", context->accessee.pkgName.c_str()); + return; + } + OHOS::DistributedDeviceProfile::LocalServiceInfo srvInfo; + auto ret = DeviceProfileConnector::GetInstance().GetLocalServiceInfoByBundleNameAndPinExchangeType( + context->accessee.pkgName, context->authType, srvInfo); + if (ret != OHOS::DistributedDeviceProfile::DP_SUCCESS) { + context->IsProxyBind = false; + context->subjectProxyOnes.clear(); + LOGI("ReadServiceInfo not found"); + return; + } + std::string srvExtarInfo = srvInfo.GetExtraInfo(); + if (srvExtarInfo.empty()) { + LOGI("no srvExtarInfo data"); + context->IsProxyBind = false; + context->subjectProxyOnes.clear(); + return; + } + JsonObject jsonObj; + jsonObj.Parse(srvExtarInfo); + if (jsonObj.IsDiscarded() || !jsonObj.Contains(APP_USER_DATA) || + !IsArray(jsonObj, APP_USER_DATA)) { + context->IsProxyBind = false; + context->subjectProxyOnes.clear(); + LOGE("no subject proxy data"); + return; + } +} + void AuthSinkNegotiateStateMachine::GetSinkCredType(std::shared_ptr context, JsonObject &credInfo, JsonObject &aclInfo, JsonObject &credTypeJson) { diff --git a/services/implementation/src/authentication_v2/dm_auth_manager_base.cpp b/services/implementation/src/authentication_v2/dm_auth_manager_base.cpp index 80d4aca64d709d7e9ae77a77328a855a6c2dbf95..9a3910b6e25051ebf2536a75b49ed831b4da5042 100644 --- a/services/implementation/src/authentication_v2/dm_auth_manager_base.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_manager_base.cpp @@ -115,6 +115,11 @@ constexpr const static char* CLOSE_PROCESS_NAME_WHITE_LIST[CLOSE_PROCESS_NAME_WH "watch_system_service" }; +constexpr const static char* PROCESS_NAME_PROXY_ADAPTATION_LIST[] = { + "gameservice_server" +}; +constexpr uint32_t PROCESS_NAME_PROXY_ADAPTATION_LIST_NUM = std::size(PROCESS_NAME_PROXY_ADAPTATION_LIST); + int32_t AuthManagerBase::AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId, const std::string &extra) { @@ -562,6 +567,25 @@ bool AuthManagerBase::CheckProcessNameInWhiteList(const std::string &processName return false; } +bool AuthManagerBase::CheckProcessNameInProxyAdaptationList(const std::string &processName) +{ + LOGI("start"); + if (processName.empty()) { + LOGE("processName is empty"); + return false; + } + uint16_t index = 0; + for (; index < PROCESS_NAME_PROXY_ADAPTATION_LIST_NUM; ++index) { + std::string whitePkgName(PROCESS_NAME_PROXY_ADAPTATION_LIST[index]); + if (processName == whitePkgName) { + LOGI("processName = %{public}s in adaptation List.", processName.c_str()); + return true; + } + } + LOGI("processName = %{public}s not in adaptation List.", processName.c_str()); + return false; +} + void AuthManagerBase::DeleteTimer() {} } // namespace DistributedHardware diff --git a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp index 789df8a059ef71633b1a2b35cfaac5cd5ddd9fb8..4b9b4479ee5005061cf92696f5a72038ae20e642 100644 --- a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp @@ -912,6 +912,7 @@ int32_t DmAuthMessageProcessor::CreateProxyNegotiateMessage(std::shared_ptrIsProxyBind; jsonObject[PARAM_KEY_IS_CALLING_PROXY_AS_SUBJECT] = context->IsCallingProxyAsSubject; if (context != nullptr && context->IsProxyBind && !context->subjectProxyOnes.empty()) { + jsonObject[TAG_AUTH_TYPE] = context->authType; JsonObject allProxyObj(JsonCreateType::JSON_CREATE_TYPE_ARRAY); for (const auto &app : context->subjectProxyOnes) { JsonObject object; @@ -1465,6 +1466,9 @@ int32_t DmAuthMessageProcessor::ParseProxyNegotiateMessage( if (!context->IsProxyBind) { return DM_OK; } + if (IsInt32(jsonObject, TAG_AUTH_TYPE)) { + context->authType = static_cast(jsonObject[TAG_AUTH_TYPE].Get()); + } if (IsBool(jsonObject, PARAM_KEY_IS_CALLING_PROXY_AS_SUBJECT)) { context->IsCallingProxyAsSubject = jsonObject[PARAM_KEY_IS_CALLING_PROXY_AS_SUBJECT].Get(); } @@ -1574,6 +1578,8 @@ int32_t DmAuthMessageProcessor::ParseMessageProxyRespAclNegotiate(const JsonObje context->IsProxyBind = false; LOGE("sink does not support proxy"); return DM_OK; + } else if (IsBool(jsonObject, PARAM_KEY_IS_PROXY_BIND)) { + context->IsProxyBind = jsonObject[PARAM_KEY_IS_PROXY_BIND].Get(); } if (!context->IsProxyBind) { return DM_OK;