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