• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 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 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
24 #include "form_share_info.h"
25 #endif
26 #include "iremote_broker.h"
27 #ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
28 #include "mission_info.h"
29 #include "mission/distributed_mission_info.h"
30 #include "mission_snapshot.h"
31 #endif
32 #include "want.h"
33 
34 namespace OHOS {
35 namespace DistributedSchedule {
36 class IDistributedSched : public OHOS::IRemoteBroker {
37 public:
38     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedSchedule.IDistributedSched");
39     enum {
40         SAME_ACCOUNT_TYPE = 0,
41         DIFF_ACCOUNT_TYPE,
42     };
43     struct AccountInfo {
44         int32_t accountType = DIFF_ACCOUNT_TYPE;
45         std::vector<std::string> groupIdList;
46     };
47     enum {
48         CALLER = 0,
49         CALLEE,
50     };
51     enum {
52         CONNECT = 0,
53         CALL,
54     };
55 
56     struct FreeInstallInfo {
57         OHOS::AAFwk::Want want;
58         int32_t requestCode = OHOS::AAFwk::DEFAULT_INVAL_VALUE;
59         CallerInfo callerInfo = {};
60         AccountInfo accountInfo = {};
61     };
62 
63     virtual int32_t StartRemoteAbility(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
64         uint32_t accessToken) = 0;
65     virtual int32_t StartAbilityFromRemote(const OHOS::AAFwk::Want& want,
66         const OHOS::AppExecFwk::AbilityInfo& abilityInfo, int32_t requestCode, const CallerInfo& callerInfo,
67         const AccountInfo& accountInfo) = 0;
68     virtual int32_t SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode,
69         const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t resultCode) = 0;
70     virtual int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
71         int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) = 0;
72     virtual int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid,
73         int32_t status, uint32_t accessToken) = 0;
74     virtual void NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess) = 0;
75     virtual int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess) = 0;
76     virtual int32_t ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
77         int32_t callerUid, int32_t callerPid, uint32_t accessToken) = 0;
78     virtual int32_t DisconnectRemoteAbility(const sptr<IRemoteObject>& connect, int32_t callerUid,
79         uint32_t accessToken) = 0;
80     virtual int32_t ConnectAbilityFromRemote(const OHOS::AAFwk::Want& want, const AppExecFwk::AbilityInfo& abilityInfo,
81         const sptr<IRemoteObject>& connect, const CallerInfo& callerInfo, const AccountInfo& accountInfo) = 0;
82     virtual int32_t DisconnectAbilityFromRemote(const sptr<IRemoteObject>& connect,
83         int32_t uid, const std::string& sourceDeviceId) = 0;
84     virtual int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) = 0;
85 #ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
86     virtual int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) = 0;
87     virtual int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
88         std::vector<DstbMissionInfo>& missionInfos) = 0;
89     virtual int32_t StopSyncRemoteMissions(const std::string& devId) = 0;
90     virtual int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) = 0;
91     virtual int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) = 0;
92     virtual int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) = 0;
93     virtual int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions,
94         std::vector<AAFwk::MissionInfo>& missionInfos) = 0;
95     virtual int32_t GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
96         std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) = 0;
97     virtual int32_t NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
98          const CallerInfo& callerInfo) = 0;
99 #endif
100     virtual int32_t StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
101         int32_t callerUid, int32_t callerPid, uint32_t accessToken) = 0;
102     virtual int32_t ReleaseRemoteAbility(const sptr<IRemoteObject>& connect,
103         const AppExecFwk::ElementName &element) = 0;
104     virtual int32_t StartAbilityByCallFromRemote(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
105         const CallerInfo& callerInfo, const AccountInfo& accountInfo) = 0;
106     virtual int32_t ReleaseAbilityFromRemote(const sptr<IRemoteObject>& connect, const AppExecFwk::ElementName &element,
107         const CallerInfo& callerInfo) = 0;
StartRemoteFreeInstall(const OHOS::AAFwk::Want & want,int32_t callerUid,int32_t requestCode,uint32_t accessToken,const sptr<IRemoteObject> & callback)108     virtual int32_t StartRemoteFreeInstall(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
109         uint32_t accessToken, const sptr<IRemoteObject>& callback)
110     {
111         return 0;
112     }
StartFreeInstallFromRemote(const FreeInstallInfo & info,int64_t taskId)113     virtual int32_t StartFreeInstallFromRemote(const FreeInstallInfo& info, int64_t taskId)
114     {
115         return 0;
116     }
NotifyCompleteFreeInstallFromRemote(int64_t taskId,int32_t resultCode)117     virtual int32_t NotifyCompleteFreeInstallFromRemote(int64_t taskId, int32_t resultCode)
118     {
119         return 0;
120     }
121 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
122     virtual int32_t StartRemoteShareForm(const std::string& remoteDeviceId,
123         const OHOS::AppExecFwk::FormShareInfo& formShareInfo) = 0;
124     virtual int32_t StartShareFormFromRemote(
125         const std::string& remoteDeviceId, const OHOS::AppExecFwk::FormShareInfo& formShareInfo) = 0;
126 #endif
127     virtual int32_t GetDistributedComponentList(std::vector<std::string>& distributedComponents) = 0;
128     enum {
129         START_REMOTE_ABILITY = 1,
130         STOP_REMOTE_ABILITY = 3,
131         START_ABILITY_FROM_REMOTE = 4,
132         STOP_ABILITY_FROM_REMOTE = 5,
133         CONNECT_REMOTE_ABILITY = 6,
134         DISCONNECT_REMOTE_ABILITY = 7,
135         CONNECT_ABILITY_FROM_REMOTE = 8,
136         DISCONNECT_ABILITY_FROM_REMOTE = 9,
137         START_CONTINUATION = 11,
138         NOTIFY_COMPLETE_CONTINUATION = 12,
139         NOTIFY_CONTINUATION_RESULT_FROM_REMOTE = 13,
140         REGISTER_ABILITY_TOKEN = 14,
141         UNREGISTER_ABILITY_TOKEN = 15,
142         CONTINUE_ABILITY = 16,
143         NOTIFY_PROCESS_DIED_FROM_REMOTE = 17,
144         SEND_RESULT_FROM_REMOTE = 20,
145         GET_REMOTE_APPTHREAD = 35,
146         CONTINUE_MISSION = 36,
147 
148         // requeset code for free install
149         START_FREE_INSTALL_FROM_REMOTE = 51,
150         NOTIFY_COMPLETE_FREE_INSTALL_FROM_REMOTE = 52,
151 
152         // request code for mission
153         GET_MISSION_INFOS = 80,
154         REGISTER_MISSION_LISTENER = 84,
155         UNREGISTER_MISSION_LISTENER = 85,
156         START_SYNC_MISSIONS_FROM_REMOTE = 86,
157         STOP_SYNC_MISSIONS_FROM_REMOTE = 87,
158         CHECK_SUPPORTED_OSD = 88,
159         CHECK_SUPPORT_OSD_FROM_REMOTE = 89,
160         MISSION_CHANGED = 90,
161         NOTIFY_MISSIONS_CHANGED_FROM_REMOTE = 91,
162         START_SYNC_MISSIONS = 92,
163         TRY_OPENP2PSESSION_FROM_REMOTE = 93,
164         SWITCH_CHANGED = 94,
165         NOTIFY_SWITCH_CHANGED_FROM_REMOTE = 95,
166         GET_CACHED_SUPPORTED_OSD = 96,
167         ALL_CONNECT_TO_DMS = 97,
168         STOP_SYNC_MISSIONS = 98,
169         GET_REMOTE_MISSION_SNAPSHOT_INFO = 99,
170 
171         // request code for call ability
172         START_REMOTE_ABILITY_BY_CALL = 150,
173         RELEASE_REMOTE_ABILITY = 151,
174         START_ABILITY_BY_CALL_FROM_REMOTE = 152,
175         RELEASE_ABILITY_FROM_REMOTE = 153,
176 
177         START_REMOTE_FREE_INSTALL = 200,
178         // request code for upload distributed component info
179         GET_DISTRIBUTED_COMPONENT_LIST = 161,
180 
181         // form share
182         START_REMOTE_SHARE_FORM = 220,
183         START_SHARE_FORM_FROM_REMOTE = 221,
184     };
185 };
186 } // namespace DistributedSchedule
187 } // namespace OHOS
188 #endif // OHOS_DISTRIBUTED_SCHED_INTERFACE_H
189