• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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, int32_t missionId,
77         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     }
ConnectDExtAbility(std::string & bundleName,std::string & abilityName,int32_t userId)117     virtual int32_t ConnectDExtAbility(std::string& bundleName, std::string& abilityName, int32_t userId)
118     {
119         return 0;
120     }
121 #ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
122     virtual int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag,
123         int32_t callingUid) = 0;
124     virtual int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
125         std::vector<DstbMissionInfo>& missionInfos) = 0;
126     virtual int32_t StopSyncRemoteMissions(const std::string& devId, int32_t callingUid) = 0;
127     virtual int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) = 0;
128     virtual int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj,
129         int32_t callingUid) = 0;
RegisterOnListener(const std::string & type,const sptr<IRemoteObject> & obj,int32_t callingUid)130     virtual int32_t RegisterOnListener(const std::string& type, const sptr<IRemoteObject>& obj, int32_t callingUid)
131     {
132         return 0;
133     }
RegisterOffListener(const std::string & type,const sptr<IRemoteObject> & obj,int32_t callingUid)134     virtual int32_t RegisterOffListener(const std::string& type, const sptr<IRemoteObject>& obj, int32_t callingUid)
135     {
136         return 0;
137     }
138     virtual int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) = 0;
139     virtual int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions,
140         std::vector<AAFwk::MissionInfo>& missionInfos) = 0;
141     virtual int32_t GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
142         std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) = 0;
143     virtual int32_t NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
144          const CallerInfo& callerInfo) = 0;
SetMissionContinueState(int32_t missionId,const AAFwk::ContinueState & state,int32_t callingUid)145     virtual int32_t SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state, int32_t callingUid)
146     {
147         return 0;
148     }
149 #endif
150     virtual int32_t StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
151         int32_t callerUid, int32_t callerPid, uint32_t accessToken) = 0;
152     virtual int32_t ReleaseRemoteAbility(const sptr<IRemoteObject>& connect,
153         const AppExecFwk::ElementName &element) = 0;
154     virtual int32_t StartAbilityByCallFromRemote(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
155         const CallerInfo& callerInfo, const AccountInfo& accountInfo) = 0;
156     virtual int32_t ReleaseAbilityFromRemote(const sptr<IRemoteObject>& connect, const AppExecFwk::ElementName &element,
157         const CallerInfo& callerInfo) = 0;
StartRemoteFreeInstall(const OHOS::AAFwk::Want & want,int32_t callerUid,int32_t requestCode,uint32_t accessToken,const sptr<IRemoteObject> & callback)158     virtual int32_t StartRemoteFreeInstall(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
159         uint32_t accessToken, const sptr<IRemoteObject>& callback)
160     {
161         return 0;
162     }
StartFreeInstallFromRemote(const FreeInstallInfo & info,int64_t taskId)163     virtual int32_t StartFreeInstallFromRemote(const FreeInstallInfo& info, int64_t taskId)
164     {
165         return 0;
166     }
NotifyCompleteFreeInstallFromRemote(int64_t taskId,int32_t resultCode)167     virtual int32_t NotifyCompleteFreeInstallFromRemote(int64_t taskId, int32_t resultCode)
168     {
169         return 0;
170     }
171 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
172     virtual int32_t StartRemoteShareForm(const std::string& remoteDeviceId,
173         const OHOS::AppExecFwk::FormShareInfo& formShareInfo) = 0;
174     virtual int32_t StartShareFormFromRemote(
175         const std::string& remoteDeviceId, const OHOS::AppExecFwk::FormShareInfo& formShareInfo) = 0;
176 #endif
177     virtual int32_t NotifyStateChangedFromRemote(int32_t abilityState, int32_t connectToken,
178         const AppExecFwk::ElementName& element) = 0;
179     virtual int32_t GetDistributedComponentList(std::vector<std::string>& distributedComponents) = 0;
180     virtual int32_t StopRemoteExtensionAbility(
181         const OHOS::AAFwk::Want& want, int32_t callerUid, uint32_t accessToken, int32_t extensionType) = 0;
182     virtual int32_t StopExtensionAbilityFromRemote(const OHOS::AAFwk::Want& want,
183         const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t extensionType) = 0;
184 };
185 } // namespace DistributedSchedule
186 } // namespace OHOS
187 #endif // OHOS_DISTRIBUTED_SCHED_INTERFACE_H
188