1 /* 2 * Copyright (c) 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 #ifndef BASE_ABILITYRUNTIME_MOCK_IABILITYMANAGER_H 16 #define BASE_ABILITYRUNTIME_MOCK_IABILITYMANAGER_H 17 18 #include "ability_manager_interface.h" 19 20 namespace OHOS { 21 namespace AAFwk { 22 class MockIAbilityManager : public IAbilityManager { 23 public: AsObject()24 sptr<IRemoteObject> AsObject() override 25 { 26 return nullptr; 27 } 28 int StartAbility( 29 const Want &want, 30 int32_t userId = DEFAULT_INVAL_VALUE, 31 int requestCode = DEFAULT_INVAL_VALUE) override 32 { 33 return 0; 34 } 35 int StartAbility( 36 const Want &want, 37 const sptr<IRemoteObject> &callerToken, 38 int32_t userId = DEFAULT_INVAL_VALUE, 39 int requestCode = DEFAULT_INVAL_VALUE) override 40 { 41 return 0; 42 } 43 int StartAbilityWithSpecifyTokenId( 44 const Want &want, 45 const sptr<IRemoteObject> &callerToken, 46 uint32_t specifyTokenId, 47 int32_t userId = DEFAULT_INVAL_VALUE, 48 int requestCode = DEFAULT_INVAL_VALUE) override 49 { 50 return 0; 51 } 52 int32_t StartAbilityByInsightIntent( 53 const Want &want, 54 const sptr<IRemoteObject> &callerToken, 55 uint64_t intentId, 56 int32_t userId = DEFAULT_INVAL_VALUE) override 57 { 58 return 0; 59 } 60 int StartAbility( 61 const Want &want, 62 const AbilityStartSetting &abilityStartSetting, 63 const sptr<IRemoteObject> &callerToken, 64 int32_t userId = DEFAULT_INVAL_VALUE, 65 int requestCode = DEFAULT_INVAL_VALUE) override 66 { 67 return 0; 68 } 69 int StartAbility( 70 const Want &want, 71 const StartOptions &startOptions, 72 const sptr<IRemoteObject> &callerToken, 73 int32_t userId = DEFAULT_INVAL_VALUE, 74 int requestCode = DEFAULT_INVAL_VALUE) override 75 { 76 return 0; 77 } 78 int TerminateAbility( 79 const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) override 80 { 81 return 0; 82 } 83 int CloseAbility(const sptr<IRemoteObject> &token, int resultCode = DEFAULT_INVAL_VALUE, 84 const Want *resultWant = nullptr) override 85 { 86 return 0; 87 } 88 int MinimizeAbility(const sptr<IRemoteObject> &token, bool fromUser = false) override 89 { 90 return 0; 91 } 92 int32_t ConnectAbility( 93 const Want &want, 94 const sptr<IAbilityConnection> &connect, 95 const sptr<IRemoteObject> &callerToken, 96 int32_t userId = DEFAULT_INVAL_VALUE) override 97 { 98 return 0; 99 } DisconnectAbility(sptr<IAbilityConnection> connect)100 int DisconnectAbility(sptr<IAbilityConnection> connect) override 101 { 102 return 0; 103 } AcquireDataAbility(const Uri & uri,bool tryBind,const sptr<IRemoteObject> & callerToken)104 sptr<IAbilityScheduler> AcquireDataAbility( 105 const Uri &uri, bool tryBind, const sptr<IRemoteObject> &callerToken) override 106 { 107 return nullptr; 108 } ReleaseDataAbility(sptr<IAbilityScheduler> dataAbilityScheduler,const sptr<IRemoteObject> & callerToken)109 int ReleaseDataAbility( 110 sptr<IAbilityScheduler> dataAbilityScheduler, const sptr<IRemoteObject> &callerToken) override 111 { 112 return 0; 113 } AttachAbilityThread(const sptr<IAbilityScheduler> & scheduler,const sptr<IRemoteObject> & token)114 int AttachAbilityThread(const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token) override 115 { 116 return 0; 117 } AbilityTransitionDone(const sptr<IRemoteObject> & token,int state,const PacMap & saveData)118 int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override 119 { 120 return 0; 121 } ScheduleConnectAbilityDone(const sptr<IRemoteObject> & token,const sptr<IRemoteObject> & remoteObject)122 int ScheduleConnectAbilityDone( 123 const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject) override 124 { 125 return 0; 126 } ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> & token)127 int ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> &token) override 128 { 129 return 0; 130 } ScheduleCommandAbilityDone(const sptr<IRemoteObject> & token)131 int ScheduleCommandAbilityDone(const sptr<IRemoteObject> &token) override 132 { 133 return 0; 134 } ScheduleCommandAbilityWindowDone(const sptr<IRemoteObject> & token,const sptr<AAFwk::SessionInfo> & sessionInfo,AAFwk::WindowCommand winCmd,AAFwk::AbilityCommand abilityCmd)135 int ScheduleCommandAbilityWindowDone( 136 const sptr<IRemoteObject> &token, 137 const sptr<AAFwk::SessionInfo> &sessionInfo, 138 AAFwk::WindowCommand winCmd, 139 AAFwk::AbilityCommand abilityCmd) override 140 { 141 return 0; 142 } DumpState(const std::string & args,std::vector<std::string> & state)143 void DumpState(const std::string &args, std::vector<std::string> &state) override 144 { 145 return; 146 } DumpSysState(const std::string & args,std::vector<std::string> & state,bool isClient,bool isUserID,int userID)147 void DumpSysState( 148 const std::string& args, std::vector<std::string>& state, bool isClient, bool isUserID, int userID) override 149 { 150 mockFunctionExcuted = true; 151 } 152 int StopServiceAbility(const Want &want, int32_t userId = DEFAULT_INVAL_VALUE, 153 const sptr<IRemoteObject> &token = nullptr) override 154 { 155 return 0; 156 } 157 int KillProcess(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0) override 158 { 159 return 0; 160 } 161 #ifdef ABILITY_COMMAND_FOR_TEST ForceTimeoutForTest(const std::string & abilityName,const std::string & state)162 int ForceTimeoutForTest(const std::string &abilityName, const std::string &state) override 163 { 164 return 0; 165 } 166 #endif 167 sptr<IWantSender> GetWantSender( 168 const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid = -1) override 169 { 170 return nullptr; 171 } SendWantSender(sptr<IWantSender> target,SenderInfo & senderInfo)172 int SendWantSender(sptr<IWantSender> target, SenderInfo &senderInfo) override 173 { 174 return 0; 175 } CancelWantSender(const sptr<IWantSender> & sender)176 void CancelWantSender(const sptr<IWantSender> &sender) override 177 { 178 return; 179 } GetPendingWantUid(const sptr<IWantSender> & target)180 int GetPendingWantUid(const sptr<IWantSender> &target) override 181 { 182 return 0; 183 } GetPendingWantUserId(const sptr<IWantSender> & target)184 int GetPendingWantUserId(const sptr<IWantSender> &target) override 185 { 186 return 0; 187 } GetPendingWantBundleName(const sptr<IWantSender> & target)188 std::string GetPendingWantBundleName(const sptr<IWantSender> &target) override 189 { 190 return ""; 191 } GetPendingWantCode(const sptr<IWantSender> & target)192 int GetPendingWantCode(const sptr<IWantSender> &target) override 193 { 194 return 0; 195 } GetPendingWantType(const sptr<IWantSender> & target)196 int GetPendingWantType(const sptr<IWantSender> &target) override 197 { 198 return 0; 199 } RegisterCancelListener(const sptr<IWantSender> & sender,const sptr<IWantReceiver> & receiver)200 void RegisterCancelListener(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver) override 201 { 202 return; 203 } UnregisterCancelListener(const sptr<IWantSender> & sender,const sptr<IWantReceiver> & receiver)204 void UnregisterCancelListener(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver) override 205 { 206 return; 207 } GetPendingRequestWant(const sptr<IWantSender> & target,std::shared_ptr<Want> & want)208 int GetPendingRequestWant(const sptr<IWantSender> &target, std::shared_ptr<Want> &want) override 209 { 210 return 0; 211 } GetWantSenderInfo(const sptr<IWantSender> & target,std::shared_ptr<WantSenderInfo> & info)212 int GetWantSenderInfo(const sptr<IWantSender> &target, std::shared_ptr<WantSenderInfo> &info) override 213 { 214 return 0; 215 } ContinueMission(const std::string & srcDeviceId,const std::string & dstDeviceId,int32_t missionId,const sptr<IRemoteObject> & callBack,AAFwk::WantParams & wantParams)216 int ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId, 217 const sptr<IRemoteObject> &callBack, AAFwk::WantParams &wantParams) override 218 { 219 return 0; 220 } ContinueAbility(const std::string & deviceId,int32_t missionId,uint32_t versionCode)221 int ContinueAbility(const std::string &deviceId, int32_t missionId, uint32_t versionCode) override 222 { 223 return 0; 224 } StartContinuation(const Want & want,const sptr<IRemoteObject> & abilityToken,int32_t status)225 int StartContinuation(const Want &want, const sptr<IRemoteObject> &abilityToken, int32_t status) override 226 { 227 return 0; 228 } NotifyCompleteContinuation(const std::string & deviceId,int32_t sessionId,bool isSuccess)229 void NotifyCompleteContinuation(const std::string &deviceId, int32_t sessionId, bool isSuccess) override 230 { 231 return; 232 } NotifyContinuationResult(int32_t missionId,int32_t result)233 int NotifyContinuationResult(int32_t missionId, int32_t result) override 234 { 235 return 0; 236 } LockMissionForCleanup(int32_t missionId)237 int LockMissionForCleanup(int32_t missionId) override 238 { 239 return 0; 240 } UnlockMissionForCleanup(int32_t missionId)241 int UnlockMissionForCleanup(int32_t missionId) override 242 { 243 return 0; 244 } RegisterMissionListener(const sptr<IMissionListener> & listener)245 int RegisterMissionListener(const sptr<IMissionListener> &listener) override 246 { 247 return 0; 248 } UnRegisterMissionListener(const sptr<IMissionListener> & listener)249 int UnRegisterMissionListener(const sptr<IMissionListener> &listener) override 250 { 251 return 0; 252 } GetMissionInfos(const std::string & deviceId,int32_t numMax,std::vector<MissionInfo> & missionInfos)253 int GetMissionInfos( 254 const std::string &deviceId, int32_t numMax, std::vector<MissionInfo> &missionInfos) override 255 { 256 return 0; 257 } GetMissionInfo(const std::string & deviceId,int32_t missionId,MissionInfo & missionInfo)258 int GetMissionInfo(const std::string &deviceId, int32_t missionId, MissionInfo &missionInfo) override 259 { 260 return 0; 261 } GetMissionSnapshot(const std::string & deviceId,int32_t missionId,MissionSnapshot & snapshot,bool isLowResolution)262 int GetMissionSnapshot(const std::string& deviceId, int32_t missionId, 263 MissionSnapshot& snapshot, bool isLowResolution) override 264 { 265 return 0; 266 } CleanMission(int32_t missionId)267 int CleanMission(int32_t missionId) override 268 { 269 return 0; 270 } CleanAllMissions()271 int CleanAllMissions() override 272 { 273 return 0; 274 } MoveMissionToFront(int32_t missionId)275 int MoveMissionToFront(int32_t missionId) override 276 { 277 return 0; 278 } MoveMissionToFront(int32_t missionId,const StartOptions & startOptions)279 int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override 280 { 281 return 0; 282 } 283 int StartAbilityByCall(const Want &want, const sptr<IAbilityConnection> &connect, 284 const sptr<IRemoteObject> &callerToken, int32_t accountId = DEFAULT_INVAL_VALUE, bool isSilent = false) override 285 { 286 return 0; 287 } ReleaseCall(const sptr<IAbilityConnection> & connect,const AppExecFwk::ElementName & element)288 int ReleaseCall(const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element) override 289 { 290 return 0; 291 } 292 int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery = false) override 293 { 294 return 0; 295 } StopUser(int userId,const sptr<IUserCallback> & callback)296 int StopUser(int userId, const sptr<IUserCallback> &callback) override 297 { 298 return 0; 299 } 300 #ifdef SUPPORT_SCREEN SetMissionLabel(const sptr<IRemoteObject> & abilityToken,const std::string & label)301 int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) override 302 { 303 return 0; 304 } SetMissionIcon(const sptr<IRemoteObject> & token,const std::shared_ptr<OHOS::Media::PixelMap> & icon)305 int SetMissionIcon(const sptr<IRemoteObject> &token, 306 const std::shared_ptr<OHOS::Media::PixelMap> &icon) override 307 { 308 return 0; 309 } CompleteFirstFrameDrawing(const sptr<IRemoteObject> & abilityToken)310 void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) override 311 { 312 return; 313 } 314 #endif GetAbilityRunningInfos(std::vector<AbilityRunningInfo> & info)315 int GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info) override 316 { 317 return 0; 318 } GetExtensionRunningInfos(int upperLimit,std::vector<ExtensionRunningInfo> & info)319 int GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info) override 320 { 321 return 0; 322 } GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> & info)323 int GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info) override 324 { 325 return 0; 326 } StartSyncRemoteMissions(const std::string & devId,bool fixConflict,int64_t tag)327 int StartSyncRemoteMissions(const std::string &devId, bool fixConflict, int64_t tag) override 328 { 329 return 0; 330 } StopSyncRemoteMissions(const std::string & devId)331 int StopSyncRemoteMissions(const std::string &devId) override 332 { 333 return 0; 334 } RegisterMissionListener(const std::string & deviceId,const sptr<IRemoteMissionListener> & listener)335 int RegisterMissionListener(const std::string &deviceId, const sptr<IRemoteMissionListener> &listener) override 336 { 337 return 0; 338 } UnRegisterMissionListener(const std::string & deviceId,const sptr<IRemoteMissionListener> & listener)339 int UnRegisterMissionListener(const std::string &deviceId, 340 const sptr<IRemoteMissionListener> &listener) override 341 { 342 return 0; 343 } SetAbilityController(const sptr<AppExecFwk::IAbilityController> & abilityController,bool imAStabilityTest)344 int SetAbilityController(const sptr<AppExecFwk::IAbilityController> &abilityController, 345 bool imAStabilityTest) override 346 { 347 return 0; 348 } IsRunningInStabilityTest()349 bool IsRunningInStabilityTest() override 350 { 351 return true; 352 } RegisterSnapshotHandler(const sptr<ISnapshotHandler> & handler)353 int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override 354 { 355 return 0; 356 } StartUserTest(const Want & want,const sptr<IRemoteObject> & observer)357 int StartUserTest(const Want &want, const sptr<IRemoteObject> &observer) override 358 { 359 return 0; 360 } FinishUserTest(const std::string & msg,const int64_t & resultCode,const std::string & bundleName)361 int FinishUserTest(const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override 362 { 363 return 0; 364 } GetTopAbility(sptr<IRemoteObject> & token)365 int GetTopAbility(sptr<IRemoteObject> &token) override 366 { 367 return 0; 368 } DelegatorDoAbilityForeground(const sptr<IRemoteObject> & token)369 int DelegatorDoAbilityForeground(const sptr<IRemoteObject> &token) override 370 { 371 return 0; 372 } DelegatorDoAbilityBackground(const sptr<IRemoteObject> & token)373 int DelegatorDoAbilityBackground(const sptr<IRemoteObject> &token) override 374 { 375 return 0; 376 } DoAbilityForeground(const sptr<IRemoteObject> & token,uint32_t flag)377 int DoAbilityForeground(const sptr<IRemoteObject> &token, uint32_t flag) override 378 { 379 return 0; 380 } DoAbilityBackground(const sptr<IRemoteObject> & token,uint32_t flag)381 int DoAbilityBackground(const sptr<IRemoteObject> &token, uint32_t flag) override 382 { 383 return 0; 384 } GetMissionIdByToken(const sptr<IRemoteObject> & token)385 int32_t GetMissionIdByToken(const sptr<IRemoteObject> &token) override 386 { 387 return 0; 388 } GetAbilityTokenByCalleeObj(const sptr<IRemoteObject> & callStub,sptr<IRemoteObject> & token)389 void GetAbilityTokenByCalleeObj(const sptr<IRemoteObject> &callStub, sptr<IRemoteObject> &token) override 390 { 391 return; 392 } IsValidMissionIds(const std::vector<int32_t> & missionIds,std::vector<MissionValidResult> & results)393 int32_t IsValidMissionIds( 394 const std::vector<int32_t> &missionIds, std::vector<MissionValidResult> &results) override 395 { 396 return 0; 397 } ReportDrawnCompleted(const sptr<IRemoteObject> & callerToken)398 int32_t ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken) override 399 { 400 return 0; 401 } RegisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener)402 int32_t RegisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener) override 403 { 404 return 0; 405 } UnregisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener)406 int32_t UnregisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener) override 407 { 408 return 0; 409 } AttachAppDebug(const std::string & bundleName,bool isDebugFromLocal)410 int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override 411 { 412 return 0; 413 } DetachAppDebug(const std::string & bundleName,bool isDebugFromLocal)414 int32_t DetachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override 415 { 416 return 0; 417 } ExecuteIntent(uint64_t key,const sptr<IRemoteObject> & callerToken,const InsightIntentExecuteParam & param)418 int32_t ExecuteIntent(uint64_t key, const sptr<IRemoteObject> &callerToken, 419 const InsightIntentExecuteParam ¶m) override 420 { 421 return 0; 422 } ExecuteInsightIntentDone(const sptr<IRemoteObject> & token,uint64_t intentId,const InsightIntentExecuteResult & result)423 int32_t ExecuteInsightIntentDone(const sptr<IRemoteObject> &token, uint64_t intentId, 424 const InsightIntentExecuteResult &result) override 425 { 426 return 0; 427 } SetApplicationAutoStartupByEDM(const AutoStartupInfo & info,bool flag)428 int32_t SetApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override 429 { 430 return 0; 431 } CancelApplicationAutoStartupByEDM(const AutoStartupInfo & info,bool flag)432 int32_t CancelApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override 433 { 434 return 0; 435 } GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> & list)436 int32_t GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> &list) override 437 { 438 return 0; 439 } ScheduleClearRecoveryPageStack()440 void ScheduleClearRecoveryPageStack() override 441 { 442 mockFunctionExcuted = true; 443 } NotifyFrozenProcessByRSS(const std::vector<int32_t> & pidList,int32_t uid)444 void NotifyFrozenProcessByRSS(const std::vector<int32_t> &pidList, int32_t uid) override 445 { 446 mockFunctionExcuted = true; 447 } KillProcessWithPrepareTerminateDone(const std::string & moduleName,int32_t prepareTermination,bool isExist)448 void KillProcessWithPrepareTerminateDone(const std::string &moduleName, 449 int32_t prepareTermination, bool isExist) override 450 { 451 mockFunctionExcuted = true; 452 } 453 bool mockFunctionExcuted = false; 454 }; 455 } // namespace AAFwk 456 } // namespace OHOS 457 #endif