1 /* 2 * Copyright (c) 2022 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 ABILITY_CONNECT_HELPER_H 17 #define ABILITY_CONNECT_HELPER_H 18 19 #include <string> 20 21 #include "ability_connect_callback_interface.h" 22 #include "ability_connect_callback_stub.h" 23 #include "element_name.h" 24 #include "iremote_stub.h" 25 #include "want.h" 26 27 #define AVSESSION_START_CALL_ABILITY_CODE 1032 28 29 namespace OHOS::AVSession { 30 class AbilityConnectHelper { 31 public: 32 static AbilityConnectHelper& GetInstance(); 33 34 int32_t StartAbilityForegroundByCall(const std::string& bundleName, const std::string& abilityName); 35 36 int32_t StartAbilityByCall(const std::string &bundleName, const std::string &abilityName); 37 38 private: 39 sptr<IRemoteObject> GetSystemAbility(); 40 41 const std::u16string ABILITY_MANAGER_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager"; 42 }; 43 44 class AbilityConnectionStub : public IRemoteStub<AAFwk::IAbilityConnection> { 45 public: 46 AbilityConnectionStub(); 47 virtual ~AbilityConnectionStub(); 48 49 int OnRemoteRequest( 50 uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; 51 52 private: 53 DISALLOW_COPY_AND_MOVE(AbilityConnectionStub); 54 }; 55 56 class AbilityConnectCallback : public AbilityConnectionStub { 57 public: AbilityConnectCallback()58 AbilityConnectCallback() {}; 59 ~AbilityConnectCallback() override; 60 61 void OnAbilityConnectDone( 62 const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode) override; 63 void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) override; 64 }; 65 } // namespace OHOS::AVSession 66 #endif /* ABILITY_CONNECT_HELPER_H */