1 /*
2  * Copyright (c) 2021-2023 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_BUNDLEMANAGERSERVICE_SLITE_FEATURE_H
17 #define OHOS_BUNDLEMANAGERSERVICE_SLITE_FEATURE_H
18 
19 #include "gt_bundle_manager_service.h"
20 #include "bundle_service_interface.h"
21 #include "feature.h"
22 #include "iproxy_client.h"
23 #include "iunknown.h"
24 #include "nocopyable.h"
25 
26 namespace OHOS {
27 const unsigned int BMS_INSTALL_MSG = 100;
28 typedef int32 (*InvokeFunc)(const void *origin, IpcIo *req);
29 
30 class BundleMgrSliteFeature : public Feature {
31 public:
32     static bool Install(const char *hapPath, const InstallParam *installParam, InstallerCallback installerCallback);
33     static bool Uninstall(const char *bundleName, const InstallParam *installParam,
34         InstallerCallback installerCallback);
35     static uint8_t QueryAbilityInfo(const Want *want, AbilityInfo *abilityInfo);
36     static uint8_t GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo *bundleInfo);
37     static uint8_t GetBundleInfos(int32_t flags, BundleInfo **bundleInfos, int32_t *len);
38     static bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess);
39     static uint32_t GetBundleSize (const char *bundleName);
40     static bool RegisterInstallerCallback(InstallerCallback installerCallback);
41     static void UpdateBundleInfoList();
42     static uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len);
43     static uint8_t QueryAbilityInfos(const Want *want, AbilityInfo **abilityInfo, int32_t *len);
44     static bool RegisterEvent(InstallerCallback installerCallback);
45     static bool UnregisterEvent(InstallerCallback installerCallback);
46     static PreAppList *InitPreAppInfo();
47     static void InsertPreAppInfo(const char *filePath, PreAppList *list);
48     static void SetPreAppInfo(PreAppList *list);
49     static void Init();
50 
GetInstance()51     static BundleMgrSliteFeature *GetInstance()
52     {
53         static BundleMgrSliteFeature instance;
54         return &instance;
55     }
56     ~BundleMgrSliteFeature() = default;
57     Identity *GetIdentity();
58 
59 private:
60     BundleMgrSliteFeature();
61     static const char *GetFeatureName(Feature *feature);
62     static void OnFeatureInitialize(Feature *feature, Service *parent, Identity identity);
63     static void OnFeatureStop(Feature *feature, Identity identity);
64     static BOOL OnFeatureMessage(Feature *feature, Request *request);
65 
66 private:
67     Identity identity_;
68     GtManagerService *gtManagerService_;
69     DISALLOW_COPY_AND_MOVE(BundleMgrSliteFeature);
70 };
71 
72 typedef struct {
73     INHERIT_IUNKNOWNENTRY(BmsSliteInterface);
74     BundleMgrSliteFeature *bms;
75 } BundleMgrSliteFeatureImpl;
76 } // namespace OHOS
77 #endif // OHOS_BUNDLEMANAGERSERVICE_SLITE_FEATURE_H
78