1 /* 2 * Copyright (c) 2021 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 IF_LOCAL_ABILITY_MANAGER_H 17 #define IF_LOCAL_ABILITY_MANAGER_H 18 19 #include <string> 20 #include <unordered_map> 21 #include "iremote_broker.h" 22 #include "iremote_object.h" 23 #include "iremote_stub.h" 24 #include "iremote_proxy.h" 25 #include "nlohmann/json.hpp" 26 #include "safwk_ipc_interface_code.h" 27 28 namespace OHOS { 29 enum { 30 IPC_STAT_CMD_START = 0, 31 IPC_STAT_CMD_STOP = 1, 32 IPC_STAT_CMD_GET = 2, 33 IPC_STAT_CMD_MAX = 3 34 }; 35 enum { 36 FFRT_STAT_CMD_START = 0, 37 FFRT_STAT_CMD_STOP = 1, 38 FFRT_STAT_CMD_GET = 2, 39 FFRT_STAT_CMD_MAX = 3 40 }; 41 class SystemAbilityExtensionPara { 42 public: SystemAbilityExtensionPara()43 SystemAbilityExtensionPara() 44 { 45 data_ = nullptr; 46 reply_ = nullptr; 47 }; ~SystemAbilityExtensionPara()48 virtual ~SystemAbilityExtensionPara() {}; 49 50 MessageParcel *data_; 51 MessageParcel *reply_; InputParaSet(MessageParcel & data)52 virtual bool InputParaSet(MessageParcel& data) 53 { 54 (void)data; 55 return true; 56 }; OutputParaGet(MessageParcel & reply)57 virtual bool OutputParaGet(MessageParcel& reply) 58 { 59 (void)reply; 60 return true; 61 }; 62 }; 63 class ILocalAbilityManager : public IRemoteBroker { 64 public: 65 virtual bool StartAbility(int32_t systemAbilityId, const std::string& eventStr) = 0; 66 virtual bool StopAbility(int32_t systemAbilityId, const std::string& eventStr) = 0; 67 virtual bool ActiveAbility(int32_t systemAbilityId, 68 const nlohmann::json& activeReason) = 0; 69 virtual bool IdleAbility(int32_t systemAbilityId, 70 const nlohmann::json& idleReason, int32_t& delayTime) = 0; 71 virtual bool SendStrategyToSA(int32_t type, int32_t systemAbilityId, int32_t level, std::string& action) = 0; 72 virtual bool IpcStatCmdProc(int32_t fd, int32_t cmd) = 0; 73 virtual bool FfrtStatCmdProc(int32_t fd, int32_t cmd) = 0; 74 virtual bool FfrtDumperProc(std::string& result) = 0; 75 virtual int32_t SystemAbilityExtProc(const std::string& extension, int32_t said, 76 SystemAbilityExtensionPara* callback, bool isAsync = false) = 0; 77 virtual int32_t ServiceControlCmd(int32_t fd, int32_t systemAbilityId, 78 const std::vector<std::u16string>& args) = 0; 79 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ILocalAbilityManager"); 80 protected: 81 static inline const std::u16string LOCAL_ABILITY_MANAGER_INTERFACE_TOKEN = u"ohos.localabilitymanager.accessToken"; 82 }; 83 } 84 #endif // !defined(IF_LOCAL_ABILITY_MANAGER_H) 85