1 /* 2 * Copyright (c) 2020 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_ABILITY_SCHEDULER_H 17 #define OHOS_ABILITY_SCHEDULER_H 18 19 #include <app_info.h> 20 21 #include "ability_event_handler.h" 22 #include "nocopyable.h" 23 #include "ipc_skeleton.h" 24 #include "want.h" 25 26 namespace OHOS { 27 const int32_t DEFAULT_IPC_SIZE = 200; 28 class Scheduler { 29 public: 30 virtual ~Scheduler() = default; 31 32 /* perform application start and stop */ 33 virtual void PerformAppInit(const AppInfo& appInfo) = 0; 34 virtual void PerformAppExit() = 0; 35 36 /* perform transact ability lifecycle state */ 37 virtual void PerformTransactAbilityState(const Want &want, int state, uint64_t token, int abilityType) = 0; 38 /* perform connect ability */ 39 virtual void PerformConnectAbility(const Want &want, uint64_t token) = 0; 40 virtual void PerformDisconnectAbility(const Want &want, uint64_t token) = 0; 41 /* perform dump ability info */ 42 virtual void PerformDumpAbility(const Want &want, uint64_t token) = 0; 43 }; 44 45 class AbilityScheduler : public NoCopyable { 46 public: 47 AbilityScheduler() = delete; 48 AbilityScheduler(AbilityEventHandler &eventHandler, Scheduler &scheduler); 49 ~AbilityScheduler() override = default; 50 51 static int32_t AmsCallback(uint32_t code, IpcIo *data, IpcIo *reply, MessageOption option); 52 53 private: 54 void PerformAppInit(const AppInfo& appInfo); 55 void PerformTransactAbilityState(const Want &want, int state, uint64_t token, int abilityType); 56 void PerformConnectAbility(const Want &want, uint64_t token); 57 void PerformDisconnectAbility(const Want &want, uint64_t token); 58 void PerformAppExit(); 59 void PerformDumpAbility(const Want &want, uint64_t token); 60 61 AbilityEventHandler &eventHandler_; 62 Scheduler &scheduler_; 63 }; 64 } // namespace OHOS 65 #endif // OHOS_ABILITY_SCHEDULER_H 66