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