• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_background_connection.h"
17 
18 #include "fms_log_wrapper.h"
19 #include "form_constants.h"
20 #include "form_mgr_proxy.h"
21 #include "form_supply_callback.h"
22 #include "form_task_mgr.h"
23 #include "want.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
FormBackgroundConnection(const int64_t formId,const std::string & bundleName,const std::string & abilityName,const std::string & funcName,const std::string & params)27 FormBackgroundConnection::FormBackgroundConnection(const int64_t formId, const std::string &bundleName,
28     const std::string &abilityName, const std::string &funcName, const std::string &params)
29     : formId_(formId), funcName_(funcName), params_(params)
30 {
31     SetProviderKey(bundleName, abilityName);
32 }
33 /**
34  * @brief OnAbilityConnectDone, AbilityMs notify caller ability the result of connect.
35  * @param element service ability's ElementName.
36  * @param remoteObject the session proxy of service ability.
37  * @param resultCode ERR_OK on success, others on failure.
38  */
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int resultCode)39 void FormBackgroundConnection::OnAbilityConnectDone(
40     const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode)
41 {
42     HILOG_DEBUG("called.");
43     if (resultCode != ERR_OK) {
44         HILOG_ERROR("%{public}s, abilityName:%{public}s, resultCode:%{public}d",
45             __func__, element.GetAbilityName().c_str(), resultCode);
46         return;
47     }
48     HILOG_DEBUG("%{public}lld formId.", (long long)formId_);
49     sptr<IFormMgr> formMgrProxy = iface_cast<IFormMgr>(remoteObject);
50     if (formMgrProxy == nullptr) {
51         HILOG_ERROR("Failed to get formMgrProxy");
52         return;
53     }
54     formMgrProxy->SetBackgroundFunction(funcName_, params_);
55     FormSupplyCallback::GetInstance()->RemoveConnection(this->GetConnectId());
56     HILOG_DEBUG("end.");
57 }
58 }  // namespace AppExecFwk
59 }  // namespace OHOS