1 /* 2 * Copyright (c) 2021-2024 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_DISTRIBUTED_SCHED_INTERFACE_H 17 #define OHOS_DISTRIBUTED_SCHED_INTERFACE_H 18 19 #include <vector> 20 #include "ability_info.h" 21 #include "ability_manager_interface.h" 22 #include "caller_info.h" 23 #include "distributed_sched_types.h" 24 #include "distributedsched_ipc_interface_code.h" 25 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE 26 #include "form_share_info.h" 27 #endif 28 #include "iremote_broker.h" 29 #ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER 30 #include "mission_info.h" 31 #include "mission/distributed_mission_info.h" 32 #include "mission_snapshot.h" 33 #endif 34 #include "want.h" 35 36 namespace OHOS { 37 namespace DistributedSchedule { 38 class IDistributedSched : public OHOS::IRemoteBroker { 39 public: 40 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedSchedule.IDistributedSched"); 41 enum { 42 SAME_ACCOUNT_TYPE = 0, 43 DIFF_ACCOUNT_TYPE, 44 }; 45 struct AccountInfo { 46 int32_t accountType = DIFF_ACCOUNT_TYPE; 47 std::vector<std::string> groupIdList; 48 std::string activeAccountId = ""; 49 int32_t userId = -1; 50 }; 51 52 enum { 53 CALLER = 0, 54 CALLEE, 55 }; 56 57 enum { 58 CONNECT = 0, 59 CALL, 60 }; 61 62 struct FreeInstallInfo { 63 OHOS::AAFwk::Want want; 64 int32_t requestCode = OHOS::AAFwk::DEFAULT_INVAL_VALUE; 65 CallerInfo callerInfo = {}; 66 AccountInfo accountInfo = {}; 67 }; 68 69 virtual int32_t StartRemoteAbility(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode, 70 uint32_t accessToken) = 0; 71 virtual int32_t StartAbilityFromRemote(const OHOS::AAFwk::Want& want, 72 const OHOS::AppExecFwk::AbilityInfo& abilityInfo, int32_t requestCode, const CallerInfo& callerInfo, 73 const AccountInfo& accountInfo) = 0; 74 virtual int32_t SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode, 75 const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t resultCode) = 0; 76 virtual int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId, 77 int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) = 0; ContinueMission(const std::string & srcDeviceId,const std::string & dstDeviceId,const std::string & bundleName,const sptr<IRemoteObject> & callback,const OHOS::AAFwk::WantParams & wantParams)78 virtual int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId, 79 const std::string& bundleName, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) 80 { 81 return 0; 82 } 83 virtual int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid, 84 int32_t status, uint32_t accessToken) = 0; 85 virtual void NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess) = 0; 86 virtual int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess, 87 const std::string dstInfo) = 0; NotifyDSchedEventResultFromRemote(const std::string type,int32_t dSchedEventResult)88 virtual int32_t NotifyDSchedEventResultFromRemote(const std::string type, int32_t dSchedEventResult) 89 { 90 return 0; 91 } 92 virtual int32_t ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect, 93 int32_t callerUid, int32_t callerPid, uint32_t accessToken) = 0; 94 virtual int32_t DisconnectRemoteAbility(const sptr<IRemoteObject>& connect, int32_t callerUid, 95 uint32_t accessToken) = 0; 96 virtual int32_t ConnectAbilityFromRemote(const OHOS::AAFwk::Want& want, const AppExecFwk::AbilityInfo& abilityInfo, 97 const sptr<IRemoteObject>& connect, const CallerInfo& callerInfo, const AccountInfo& accountInfo) = 0; 98 virtual int32_t DisconnectAbilityFromRemote(const sptr<IRemoteObject>& connect, 99 int32_t uid, const std::string& sourceDeviceId) = 0; 100 virtual int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) = 0; RegisterDSchedEventListener(const DSchedEventType & type,const sptr<IRemoteObject> & obj)101 virtual int32_t RegisterDSchedEventListener(const DSchedEventType& type, const sptr<IRemoteObject>& obj) 102 { 103 return 0; 104 } UnRegisterDSchedEventListener(const DSchedEventType & type,const sptr<IRemoteObject> & obj)105 virtual int32_t UnRegisterDSchedEventListener(const DSchedEventType& type, const sptr<IRemoteObject>& obj) 106 { 107 return 0; 108 } GetContinueInfo(std::string & dstNetworkId,std::string & srcNetworkId)109 virtual int32_t GetContinueInfo(std::string& dstNetworkId, std::string& srcNetworkId) 110 { 111 return 0; 112 } GetDSchedEventInfo(const DSchedEventType & type,std::vector<EventNotify> & events)113 virtual int32_t GetDSchedEventInfo(const DSchedEventType &type, std::vector<EventNotify> &events) 114 { 115 return 0; 116 } 117 #ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER 118 virtual int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) = 0; 119 virtual int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo, 120 std::vector<DstbMissionInfo>& missionInfos) = 0; 121 virtual int32_t StopSyncRemoteMissions(const std::string& devId) = 0; 122 virtual int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) = 0; 123 virtual int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) = 0; RegisterOnListener(const std::string & type,const sptr<IRemoteObject> & obj)124 virtual int32_t RegisterOnListener(const std::string& type, const sptr<IRemoteObject>& obj) 125 { 126 return 0; 127 } RegisterOffListener(const std::string & type,const sptr<IRemoteObject> & obj)128 virtual int32_t RegisterOffListener(const std::string& type, const sptr<IRemoteObject>& obj) 129 { 130 return 0; 131 } 132 virtual int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) = 0; 133 virtual int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions, 134 std::vector<AAFwk::MissionInfo>& missionInfos) = 0; 135 virtual int32_t GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId, 136 std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) = 0; 137 virtual int32_t NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos, 138 const CallerInfo& callerInfo) = 0; SetMissionContinueState(int32_t missionId,const AAFwk::ContinueState & state)139 virtual int32_t SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state) 140 { 141 return 0; 142 } 143 #endif 144 virtual int32_t StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect, 145 int32_t callerUid, int32_t callerPid, uint32_t accessToken) = 0; 146 virtual int32_t ReleaseRemoteAbility(const sptr<IRemoteObject>& connect, 147 const AppExecFwk::ElementName &element) = 0; 148 virtual int32_t StartAbilityByCallFromRemote(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect, 149 const CallerInfo& callerInfo, const AccountInfo& accountInfo) = 0; 150 virtual int32_t ReleaseAbilityFromRemote(const sptr<IRemoteObject>& connect, const AppExecFwk::ElementName &element, 151 const CallerInfo& callerInfo) = 0; StartRemoteFreeInstall(const OHOS::AAFwk::Want & want,int32_t callerUid,int32_t requestCode,uint32_t accessToken,const sptr<IRemoteObject> & callback)152 virtual int32_t StartRemoteFreeInstall(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode, 153 uint32_t accessToken, const sptr<IRemoteObject>& callback) 154 { 155 return 0; 156 } StartFreeInstallFromRemote(const FreeInstallInfo & info,int64_t taskId)157 virtual int32_t StartFreeInstallFromRemote(const FreeInstallInfo& info, int64_t taskId) 158 { 159 return 0; 160 } NotifyCompleteFreeInstallFromRemote(int64_t taskId,int32_t resultCode)161 virtual int32_t NotifyCompleteFreeInstallFromRemote(int64_t taskId, int32_t resultCode) 162 { 163 return 0; 164 } 165 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE 166 virtual int32_t StartRemoteShareForm(const std::string& remoteDeviceId, 167 const OHOS::AppExecFwk::FormShareInfo& formShareInfo) = 0; 168 virtual int32_t StartShareFormFromRemote( 169 const std::string& remoteDeviceId, const OHOS::AppExecFwk::FormShareInfo& formShareInfo) = 0; 170 #endif 171 virtual int32_t NotifyStateChangedFromRemote(int32_t abilityState, int32_t connectToken, 172 const AppExecFwk::ElementName& element) = 0; 173 virtual int32_t GetDistributedComponentList(std::vector<std::string>& distributedComponents) = 0; 174 virtual int32_t StopRemoteExtensionAbility( 175 const OHOS::AAFwk::Want& want, int32_t callerUid, uint32_t accessToken, int32_t extensionType) = 0; 176 virtual int32_t StopExtensionAbilityFromRemote(const OHOS::AAFwk::Want& want, 177 const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t extensionType) = 0; 178 }; 179 } // namespace DistributedSchedule 180 } // namespace OHOS 181 #endif // OHOS_DISTRIBUTED_SCHED_INTERFACE_H 182