• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright (c) 2025-2025 Huawei Device Co., Ltd.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "form_provider/connection/form_configuration_update_connection.h"
18 
19 #include <cinttypes>
20 
21 #include "fms_log_wrapper.h"
22 #include "form_constants.h"
23 #include "form_provider/form_supply_callback.h"
24 #include "form_provider/form_provider_task_mgr.h"
25 #include "want.h"
26 
27 namespace OHOS {
28 namespace AppExecFwk {
ConfigurationUpdateConnection(const int64_t formId,const Want & want,const std::string & bundleName,const std::string & abilityName,AppExecFwk::Configuration configuration)29 ConfigurationUpdateConnection::ConfigurationUpdateConnection(const int64_t formId, const Want& want,
30     const std::string &bundleName, const std::string &abilityName,
31     AppExecFwk::Configuration configuration): want_(want), configuration_(configuration)
32 {
33     SetFormId(formId);
34     SetProviderKey(bundleName, abilityName);
35 }
36 
37 /**
38  * @brief OnAbilityConnectDone, AbilityMs notify caller ability the result of connect.
39  *
40  * @param element Service ability's ElementName.
41  * @param remoteObject The session proxy of service ability.
42  * @param resultCode ERR_OK on success, others on failure.
43  */
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int resultCode)44 void ConfigurationUpdateConnection::OnAbilityConnectDone(
45     const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode)
46 {
47     HILOG_INFO("call");
48     FormAbilityConnection::OnAbilityConnectDone(element, remoteObject, resultCode);
49     if (resultCode != ERR_OK) {
50         HILOG_ERROR("abilityName:%{public}s, formId:%{public}" PRId64 ", resultCode:%{public}d",
51             element.GetAbilityName().c_str(), GetFormId(), resultCode);
52         return;
53     }
54     onFormAppConnect();
55     sptr<ConfigurationUpdateConnection> connection(this);
56     FormSupplyCallback::GetInstance()->AddConnection(connection);
57 
58     Want want = Want(want_);
59     want.SetParam(Constants::FORM_CONNECT_ID, this->GetConnectId());
60     FormProviderTaskMgr::GetInstance().NotifyConfigurationUpdate(configuration_, want, remoteObject);
61 }
62 }  // namespace AppExecFwk
63 }  // namespace OHOS