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_ABILITYMANAGERSERVICE_INNER_FEATURE_H
17 #define OHOS_ABILITYMANAGERSERVICE_INNER_FEATURE_H
18 
19 #include "ability_service_interface.h"
20 #include "ability_mgr_handler.h"
21 #include "feature.h"
22 #include "iproxy_client.h"
23 #include "iunknown.h"
24 #include "nocopyable.h"
25 
26 namespace OHOS {
27 typedef int32 (*InvokeFunc)(const void *origin, IpcIo *req);
28 
29 class AbilityInnerFeature : public Feature {
30 public:
31     static int32 StartKeepAliveApps();
32     static int32 TerminateApp(const char *bundleName);
33 
34     static int32 Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, IpcIo *reply);
35 
GetInstance()36     static AbilityInnerFeature *GetInstance()
37     {
38         static AbilityInnerFeature instance;
39         return &instance;
40     }
41     ~AbilityInnerFeature() = default;
42 private:
43     AbilityInnerFeature();
44 
45     static int32 TerminateAppInvoke(const void *origin, IpcIo *req);
46     static int32 DumpAbilityInvoke(const void *origin, IpcIo *req);
47 
48     static const char *GetFeatureName(Feature *feature);
49     static void OnFeatureInitialize(Feature *feature, Service *parent, Identity identity);
50     static void OnFeatureStop(Feature *feature, Identity identity);
51     static BOOL OnFeatureMessage(Feature *feature, Request *request);
52 
53 private:
54     Identity identity_;
55     static InvokeFunc invokeFuncList[COMMAND_END - INNER_BEGIN];
56     DISALLOW_COPY_AND_MOVE(AbilityInnerFeature);
57 };
58 
59 typedef struct {
60     INHERIT_IUNKNOWNENTRY(AmsInnerInterface);
61     AbilityInnerFeature *ams;
62 } AbilityInnerFeatureImpl;
63 } // namespace OHOS
64 #endif // OHOS_ABILITYMANAGERSERVICE_INNER_FEATURE_H
65