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 class SystemAbilityExtensionPara { 36 public: SystemAbilityExtensionPara()37 SystemAbilityExtensionPara() 38 { 39 data_ = nullptr; 40 reply_ = nullptr; 41 }; ~SystemAbilityExtensionPara()42 virtual ~SystemAbilityExtensionPara() {}; 43 44 MessageParcel *data_; 45 MessageParcel *reply_; InputParaSet(MessageParcel & data)46 virtual bool InputParaSet(MessageParcel& data) 47 { 48 (void)data; 49 return true; 50 }; OutputParaGet(MessageParcel & reply)51 virtual bool OutputParaGet(MessageParcel& reply) 52 { 53 (void)reply; 54 return true; 55 }; 56 }; 57 class ILocalAbilityManager : public IRemoteBroker { 58 public: 59 virtual bool StartAbility(int32_t systemAbilityId, const std::string& eventStr) = 0; 60 virtual bool StopAbility(int32_t systemAbilityId, const std::string& eventStr) = 0; 61 virtual bool ActiveAbility(int32_t systemAbilityId, 62 const nlohmann::json& activeReason) = 0; 63 virtual bool IdleAbility(int32_t systemAbilityId, 64 const nlohmann::json& idleReason, int32_t& delayTime) = 0; 65 virtual bool SendStrategyToSA(int32_t type, int32_t systemAbilityId, int32_t level, std::string& action) = 0; 66 virtual bool IpcStatCmdProc(int32_t fd, int32_t cmd) = 0; 67 virtual bool FfrtDumperProc(std::string& result) = 0; 68 virtual int32_t SystemAbilityExtProc(const std::string& extension, int32_t said, 69 SystemAbilityExtensionPara* callback, bool isAsync = false) = 0; 70 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ILocalAbilityManager"); 71 protected: 72 static inline const std::u16string LOCAL_ABILITY_MANAGER_INTERFACE_TOKEN = u"ohos.localabilitymanager.accessToken"; 73 }; 74 } 75 #endif // !defined(IF_LOCAL_ABILITY_MANAGER_H) 76