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 #include "mock_distributed_sched.h"
17 #include "dtbschedmgr_log.h"
18 #include "string_ex.h"
19
20 using namespace std;
21 using namespace OHOS::AAFwk;
22 using namespace OHOS::AppExecFwk;
23
24 namespace OHOS {
25 namespace DistributedSchedule {
StartRemoteAbility(const OHOS::AAFwk::Want & want,int32_t callerUid,int32_t requestCode,uint32_t accessToken)26 int32_t MockDistributedSched::StartRemoteAbility(const OHOS::AAFwk::Want& want,
27 int32_t callerUid, int32_t requestCode, uint32_t accessToken)
28 {
29 return 0;
30 }
31
StartAbilityFromRemote(const OHOS::AAFwk::Want & want,const OHOS::AppExecFwk::AbilityInfo & abilityInfo,int32_t requestCode,const CallerInfo & callerInfo,const AccountInfo & accountInfo)32 int32_t MockDistributedSched::StartAbilityFromRemote(const OHOS::AAFwk::Want& want,
33 const OHOS::AppExecFwk::AbilityInfo& abilityInfo, int32_t requestCode, const CallerInfo& callerInfo,
34 const AccountInfo& accountInfo)
35 {
36 return 0;
37 }
38
SendResultFromRemote(OHOS::AAFwk::Want & want,int32_t requestCode,const CallerInfo & callerInfo,const AccountInfo & accountInfo,int32_t resultCode)39 int32_t MockDistributedSched::SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode,
40 const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t resultCode)
41 {
42 return 0;
43 }
44
ContinueMission(const std::string & srcDeviceId,const std::string & dstDeviceId,int32_t missionId,const sptr<IRemoteObject> & callback,const OHOS::AAFwk::WantParams & wantParams)45 int32_t MockDistributedSched::ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
46 int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
47 {
48 return 0;
49 }
50
StartContinuation(const OHOS::AAFwk::Want & want,int32_t missionId,int32_t callerUid,int32_t status,uint32_t accessToken)51 int32_t MockDistributedSched::StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId,
52 int32_t callerUid, int32_t status, uint32_t accessToken)
53 {
54 return 0;
55 }
56
NotifyCompleteContinuation(const std::u16string & devId,int32_t sessionId,bool isSuccess)57 void MockDistributedSched::NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess)
58 {
59 (void)isSuccess;
60 }
61
NotifyContinuationResultFromRemote(int32_t sessionId,bool isSuccess,const std::string dstInfo)62 int32_t MockDistributedSched::NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess,
63 const std::string dstInfo)
64 {
65 (void)isSuccess;
66 return 0;
67 }
68
ConnectRemoteAbility(const OHOS::AAFwk::Want & want,const sptr<IRemoteObject> & connect,int32_t callerUid,int32_t callerPid,uint32_t accessToken)69 int32_t MockDistributedSched::ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
70 int32_t callerUid, int32_t callerPid, uint32_t accessToken)
71 {
72 return 0;
73 }
74
DisconnectRemoteAbility(const sptr<IRemoteObject> & connect,int32_t callerUid,uint32_t accessToken)75 int32_t MockDistributedSched::DisconnectRemoteAbility(const sptr<IRemoteObject>& connect, int32_t callerUid,
76 uint32_t accessToken)
77 {
78 return 0;
79 }
80
ConnectAbilityFromRemote(const OHOS::AAFwk::Want & want,const AppExecFwk::AbilityInfo & abilityInfo,const sptr<IRemoteObject> & connect,const CallerInfo & callerInfo,const AccountInfo & accountInfo)81 int32_t MockDistributedSched::ConnectAbilityFromRemote(const OHOS::AAFwk::Want& want,
82 const AppExecFwk::AbilityInfo& abilityInfo, const sptr<IRemoteObject>& connect,
83 const CallerInfo& callerInfo, const AccountInfo& accountInfo)
84 {
85 return 0;
86 }
87
DisconnectAbilityFromRemote(const sptr<IRemoteObject> & connect,int32_t uid,const std::string & sourceDeviceId)88 int32_t MockDistributedSched::DisconnectAbilityFromRemote(const sptr<IRemoteObject>& connect,
89 int32_t uid, const std::string& sourceDeviceId)
90 {
91 return 0;
92 }
93
NotifyProcessDiedFromRemote(const CallerInfo & callerInfo)94 int32_t MockDistributedSched::NotifyProcessDiedFromRemote(const CallerInfo& callerInfo)
95 {
96 return 0;
97 }
98
99 #ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
StartSyncRemoteMissions(const std::string & devId,bool fixConflict,int64_t tag)100 int32_t MockDistributedSched::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag)
101 {
102 return ERR_NONE;
103 }
104
RegisterMissionListener(const std::u16string & devId,const sptr<IRemoteObject> & obj)105 int32_t MockDistributedSched::RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj)
106 {
107 return ERR_NONE;
108 }
109
UnRegisterMissionListener(const std::u16string & devId,const sptr<IRemoteObject> & obj)110 int32_t MockDistributedSched::UnRegisterMissionListener(const std::u16string& devId,
111 const sptr<IRemoteObject>& obj)
112 {
113 return ERR_NONE;
114 }
115
GetRemoteMissionSnapshotInfo(const std::string & networkId,int32_t missionId,std::unique_ptr<MissionSnapshot> & missionSnapshot)116 int32_t MockDistributedSched::GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
117 std::unique_ptr<MissionSnapshot>& missionSnapshot)
118 {
119 return ERR_NONE;
120 }
121
NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo> & missionInfos,const CallerInfo & callerInfo)122 int32_t MockDistributedSched::NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
123 const CallerInfo& callerInfo)
124 {
125 expectedTrue_ = false;
126 return ERR_NONE;
127 }
128
GetMissionInfos(const std::string & deviceId,int32_t numMissions,std::vector<MissionInfo> & missionInfos)129 int32_t MockDistributedSched::GetMissionInfos(const std::string& deviceId, int32_t numMissions,
130 std::vector<MissionInfo>& missionInfos)
131 {
132 return ERR_NONE;
133 }
134
StartSyncMissionsFromRemote(const CallerInfo & callerInfo,std::vector<DstbMissionInfo> & missionInfos)135 int32_t MockDistributedSched::StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
136 std::vector<DstbMissionInfo>& missionInfos)
137 {
138 return ERR_NONE;
139 }
140
StopSyncMissionsFromRemote(const CallerInfo & callerInfo)141 int32_t MockDistributedSched::StopSyncMissionsFromRemote(const CallerInfo& callerInfo)
142 {
143 return ERR_NONE;
144 }
145
StopSyncRemoteMissions(const std::string & devId)146 int32_t MockDistributedSched::StopSyncRemoteMissions(const std::string& devId)
147 {
148 return ERR_NONE;
149 }
150
SetMissionContinueState(int32_t missionId,const AAFwk::ContinueState & state)151 int32_t MockDistributedSched::SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state)
152 {
153 return ERR_NONE;
154 }
155 #endif
156
StartRemoteAbilityByCall(const OHOS::AAFwk::Want & want,const sptr<IRemoteObject> & connect,int32_t callerUid,int32_t callerPid,uint32_t accessToken)157 int32_t MockDistributedSched::StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want,
158 const sptr<IRemoteObject>& connect, int32_t callerUid, int32_t callerPid, uint32_t accessToken)
159 {
160 return ERR_NONE;
161 }
162
ReleaseRemoteAbility(const sptr<IRemoteObject> & connect,const AppExecFwk::ElementName & element)163 int32_t MockDistributedSched::ReleaseRemoteAbility(const sptr<IRemoteObject>& connect,
164 const AppExecFwk::ElementName &element)
165 {
166 return ERR_NONE;
167 }
168
StartAbilityByCallFromRemote(const OHOS::AAFwk::Want & want,const sptr<IRemoteObject> & connect,const CallerInfo & callerInfo,const AccountInfo & accountInfo)169 int32_t MockDistributedSched::StartAbilityByCallFromRemote(const OHOS::AAFwk::Want& want,
170 const sptr<IRemoteObject>& connect, const CallerInfo& callerInfo, const AccountInfo& accountInfo)
171 {
172 return ERR_NONE;
173 }
174
ReleaseAbilityFromRemote(const sptr<IRemoteObject> & connect,const AppExecFwk::ElementName & element,const CallerInfo & callerInfo)175 int32_t MockDistributedSched::ReleaseAbilityFromRemote(const sptr<IRemoteObject>& connect,
176 const AppExecFwk::ElementName &element, const CallerInfo& callerInfo)
177 {
178 return ERR_NONE;
179 }
180
NotifyStateChangedFromRemote(int32_t abilityState,int32_t missionId,const AppExecFwk::ElementName & element)181 int32_t MockDistributedSched::NotifyStateChangedFromRemote(int32_t abilityState, int32_t missionId,
182 const AppExecFwk::ElementName& element)
183 {
184 return ERR_NONE;
185 }
186
GetDistributedComponentList(std::vector<std::string> & distributedComponents)187 int32_t MockDistributedSched::GetDistributedComponentList(std::vector<std::string>& distributedComponents)
188 {
189 return ERR_NONE;
190 }
191
StartRemoteFreeInstall(const OHOS::AAFwk::Want & want,int32_t callerUid,int32_t requestCode,uint32_t accessToken,const sptr<IRemoteObject> & callback)192 int32_t MockDistributedSched::StartRemoteFreeInstall(const OHOS::AAFwk::Want &want, int32_t callerUid,
193 int32_t requestCode, uint32_t accessToken, const sptr<IRemoteObject> &callback)
194 {
195 return ERR_NONE;
196 }
197
StartFreeInstallFromRemote(const IDistributedSched::FreeInstallInfo & info,int64_t taskId)198 int32_t MockDistributedSched::StartFreeInstallFromRemote(const IDistributedSched::FreeInstallInfo &info, int64_t taskId)
199 {
200 return ERR_NONE;
201 }
202
NotifyCompleteFreeInstallFromRemote(int64_t taskId,int32_t resultCode)203 int32_t MockDistributedSched::NotifyCompleteFreeInstallFromRemote(int64_t taskId, int32_t resultCode)
204 {
205 return ERR_NONE;
206 }
207
NotifyCompleteFreeInstall(const IDistributedSched::FreeInstallInfo & info,int64_t taskId,int32_t resultCode)208 int32_t MockDistributedSched::NotifyCompleteFreeInstall(
209 const IDistributedSched::FreeInstallInfo &info, int64_t taskId, int32_t resultCode)
210 {
211 return ERR_NONE;
212 }
213
214 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
StartRemoteShareForm(const std::string & remoteDeviceId,const OHOS::AppExecFwk::FormShareInfo & formShareInfo)215 int32_t MockDistributedSched::StartRemoteShareForm(const std::string& remoteDeviceId,
216 const OHOS::AppExecFwk::FormShareInfo& formShareInfo)
217 {
218 return ERR_NONE;
219 }
220
StartShareFormFromRemote(const std::string & remoteDeviceId,const OHOS::AppExecFwk::FormShareInfo & formShareInfo)221 int32_t MockDistributedSched::StartShareFormFromRemote(
222 const std::string& remoteDeviceId, const OHOS::AppExecFwk::FormShareInfo& formShareInfo)
223 {
224 return ERR_NONE;
225 }
226 #endif
StopRemoteExtensionAbility(const OHOS::AAFwk::Want & want,int32_t callerUid,uint32_t accessToken,int32_t extensionType)227 int32_t MockDistributedSched::StopRemoteExtensionAbility(
228 const OHOS::AAFwk::Want& want, int32_t callerUid, uint32_t accessToken, int32_t extensionType)
229 {
230 return ERR_NONE;
231 }
StopExtensionAbilityFromRemote(const OHOS::AAFwk::Want & want,const CallerInfo & callerInfo,const AccountInfo & accountInfo,int32_t extensionType)232 int32_t MockDistributedSched::StopExtensionAbilityFromRemote(const OHOS::AAFwk::Want& want,
233 const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t extensionType)
234 {
235 return ERR_NONE;
236 }
237 } // namespace DistributedSchedule
238 } // namespace OHOS