1 /* 2 * Copyright (c) 2021 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 #ifndef FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_ABILITY_CONNECTION_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_ABILITY_CONNECTION_H 18 19 #include "event_handler.h" 20 #include "form_item_info.h" 21 #include "provider_connect_stub.h" 22 #include "want.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 using WantParams = OHOS::AAFwk::WantParams; 27 28 /** 29 * @class FormAbilityConnection 30 * Form Ability Connection Stub. 31 */ 32 class FormAbilityConnection : public ProviderConnectStub { 33 public: 34 FormAbilityConnection() = default; 35 virtual ~FormAbilityConnection() = default; 36 37 /** 38 * @brief OnAbilityConnectDone, AbilityMs notify caller ability the result of connect. 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 */ 43 virtual void OnAbilityConnectDone( 44 const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode) override; 45 46 /** 47 * @brief OnAbilityDisconnectDone, AbilityMs notify caller ability the result of disconnect. 48 * @param element service ability's ElementName. 49 * @param resultCode ERR_OK on success, others on failure. 50 */ 51 virtual void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; 52 53 /** 54 * @brief remote object died event. 55 * @param remoteObject the remote object of service ability. 56 */ 57 void OnConnectDied(const wptr<IRemoteObject> &remoteObject); 58 59 /** 60 * @brief Get connectId. 61 * @return The ability connection id. 62 */ 63 long GetConnectId(); 64 65 /** 66 * @brief Set connectId. 67 * @param connectId The ability connection id. 68 */ 69 void SetConnectId(long connectId); 70 /** 71 * @brief Get the provider Key 72 * 73 * @return The provider Key 74 */ 75 std::string GetProviderKey(); 76 /** 77 * @brief Set the Provider Key 78 * 79 * @param bundleName bundleName 80 * @param abilityName abilityName 81 */ 82 void SetProviderKey(const std::string &bundleName, const std::string &abilityName); 83 84 private: 85 int64_t formId_ = 0; 86 std::string deviceId_ = ""; 87 std::string bundleName_ = ""; 88 std::string abilityName_ = ""; 89 bool isFreeInstall_ = false; 90 long connectId_ = 0; 91 92 DISALLOW_COPY_AND_MOVE(FormAbilityConnection); 93 }; 94 } // namespace AppExecFwk 95 } // namespace OHOS 96 97 #endif // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_ABILITY_CONNECTION_H