• 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_location_connection.h"
17 
18 #include <cinttypes>
19 
20 #include "fms_log_wrapper.h"
21 #include "form_constants.h"
22 #include "form_provider/form_supply_callback.h"
23 #include "form_provider/form_provider_task_mgr.h"
24 #include "data_center/form_data_mgr.h"
25 #include "want.h"
26 
27 namespace OHOS {
28 namespace AppExecFwk {
FormLocationConnection(const int64_t formId,const Want & want,const std::string & bundleName,const std::string & abilityName)29 FormLocationConnection::FormLocationConnection(const int64_t formId, const Want& want,
30     const std::string &bundleName, const std::string &abilityName) : want_(want)
31 {
32     SetFormId(formId);
33     SetProviderKey(bundleName, abilityName);
34 }
35 
36 /**
37 * @brief OnAbilityConnectDone, AbilityMs notify caller ability the result of connect.
38 *
39 * @param element Service ability's ElementName.
40 * @param remoteObject The session proxy of service ability.
41 * @param resultCode ERR_OK on success, others on failure.
42 */
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int resultCode)43 void FormLocationConnection::OnAbilityConnectDone(
44     const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode)
45 {
46     HILOG_INFO("call");
47     FormAbilityConnection::OnAbilityConnectDone(element, remoteObject, resultCode);
48     if (resultCode != ERR_OK) {
49         HILOG_ERROR("abilityName:%{public}s, formId:%{public}" PRId64 ", resultCode:%{public}d",
50             element.GetAbilityName().c_str(), GetFormId(), resultCode);
51         return;
52     }
53     onFormAppConnect();
54     sptr<FormLocationConnection> connection(this);
55     FormSupplyCallback::GetInstance()->AddConnection(connection);
56     Want want = Want(want_);
57     want.SetParam(Constants::FORM_CONNECT_ID, this->GetConnectId());
58 
59 FormProviderTaskMgr::GetInstance().PostRefreshLocationTask(GetFormId(), want, remoteObject);
60 }
61 }  // namespace AppExecFwk
62 }  // namespace OHOS