1
2 /*
3 * Copyright (c) 2021-2022 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_batch_delete_connection.h"
18
19 #include "fms_log_wrapper.h"
20 #include "form_constants.h"
21 #include "form_supply_callback.h"
22 #include "form_task_mgr.h"
23 #include "want.h"
24
25 namespace OHOS {
26 namespace AppExecFwk {
FormBatchDeleteConnection(const std::set<int64_t> & formIds,const std::string & bundleName,const std::string & abilityName)27 FormBatchDeleteConnection::FormBatchDeleteConnection(const std::set<int64_t> &formIds,
28 const std::string &bundleName, const std::string &abilityName) : formIds_(formIds)
29 {
30 SetProviderKey(bundleName, abilityName);
31 }
32 /**
33 * @brief OnAbilityConnectDone, AbilityMs notify caller ability the result of connect.
34 * @param element service ability's ElementName.
35 * @param remoteObject the session proxy of service ability.
36 * @param resultCode ERR_OK on success, others on failure.
37 */
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int resultCode)38 void FormBatchDeleteConnection::OnAbilityConnectDone(
39 const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode)
40 {
41 HILOG_INFO("call");
42 if (resultCode != ERR_OK) {
43 HILOG_ERROR("abilityName:%{public}s, resultCode:%{public}d",
44 element.GetAbilityName().c_str(), resultCode);
45 return;
46 }
47 onFormAppConnect();
48 sptr<FormBatchDeleteConnection> connection(this);
49 FormSupplyCallback::GetInstance()->AddConnection(connection);
50 Want want;
51 want.SetParam(Constants::FORM_CONNECT_ID, this->GetConnectId());
52 FormTaskMgr::GetInstance().PostProviderBatchDeleteTask(formIds_, want, remoteObject);
53 }
54 } // namespace AppExecFwk
55 } // namespace OHOS