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 #ifndef OHOS_ABILITY_RUNTIME_SERVICE_ROUTER_FRAMEWORK_INCLUDE_SERVICE_ROUTER_MANAGER_H 17 #define OHOS_ABILITY_RUNTIME_SERVICE_ROUTER_FRAMEWORK_INCLUDE_SERVICE_ROUTER_MANAGER_H 18 19 #include <string> 20 #include <vector> 21 22 #include "ability_connect_callback_interface.h" 23 #include "extension_ability_info.h" 24 #include "iremote_broker.h" 25 #include "service_info.h" 26 #include "session_info.h" 27 #include "want.h" 28 29 namespace OHOS { 30 namespace AbilityRuntime { 31 using namespace OHOS::AAFwk; 32 using namespace OHOS::AppExecFwk; 33 constexpr const char* SERVICE_ROUTER_MANAGER_SERVICE_NAME = "ServiceRouterMgrService"; 34 const int DEFAULT_INVAL_VALUE = -1; 35 36 /** 37 * @class IServiceRouterManager 38 * IServiceRouterManager interface is used to access service router manager services. 39 */ 40 class IServiceRouterManager : public IRemoteBroker { 41 public: 42 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.ServiceRouterManager") 43 44 /** 45 * @brief Query the business ability info of list by the given filter. 46 * @param filter Indicates the filter containing the business ability info to be queried. 47 * @param businessAbilityInfos Indicates the obtained business ability info objects 48 * @return Returns ERR_OK on success, others on failure. 49 */ 50 virtual int32_t QueryBusinessAbilityInfos(const BusinessAbilityFilter &filter, 51 std::vector<BusinessAbilityInfo> &businessAbilityInfos) = 0; 52 53 /** 54 * @brief Query the PurposeInfo of list by the given Want. 55 * @param want Indicates the information of the purpose. 56 * @param purposeName Indicates the purposeName. 57 * @param purposeInfos Indicates the obtained PurposeInfos object. 58 * @return Returns ERR_OK on success, others on failure. 59 */ 60 virtual int32_t QueryPurposeInfos(const Want &want, const std::string purposeName, 61 std::vector<PurposeInfo> &purposeInfos) = 0; 62 63 /** 64 * Start ui extension ability with extension session info, send extension session info to ability manager service. 65 * 66 * @param sessionInfo the extension session info of the ability to start. 67 * @param userId, Designation User ID. 68 * @return Returns ERR_OK on success, others on failure. 69 */ 70 virtual int32_t StartUIExtensionAbility(const sptr<SessionInfo> &sessionInfo, 71 int32_t userId = DEFAULT_INVAL_VALUE) 72 { 73 return 0; 74 } 75 76 /** 77 * Connect ui extension ability with want, connect session with service ability. 78 * 79 * @param want, Special want for service type's ability. 80 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 81 * @param sessionInfo the extension session info of the ability to start. 82 * @param userId, Designation User ID. 83 * @return Returns ERR_OK on success, others on failure. 84 */ 85 virtual int32_t ConnectUIExtensionAbility(const Want &want, const sptr<IAbilityConnection> &connect, 86 const sptr<SessionInfo> &sessionInfo, int32_t userId = DEFAULT_INVAL_VALUE) 87 { 88 return 0; 89 } 90 91 enum Message : uint32_t { 92 QUERY_BUSINESS_ABILITY_INFOS = 0, 93 QUERY_PURPOSE_INFOS = 1, 94 START_UI_EXTENSION = 2, 95 CONNECT_UI_EXTENSION = 3, 96 }; 97 }; 98 } // namespace AbilityRuntime 99 } // namespace OHOS 100 #endif // OHOS_ABILITY_RUNTIME_SERVICE_ROUTER_FRAMEWORK_INCLUDE_SERVICE_ROUTER_MANAGER_H 101