• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 DRIVER_PKG_MANAGER_H
17 #define DRIVER_PKG_MANAGER_H
18 
19 #include <iostream>
20 #include <stdint.h>
21 
22 #include "bundle_monitor.h"
23 #include "drv_bundle_state_callback.h"
24 #include "ibus_extension.h"
25 #include "single_instance.h"
26 #include "ext_object.h"
27 namespace OHOS {
28 namespace ExternalDeviceManager {
29 using namespace std;
30 using namespace OHOS;
31 using namespace OHOS::AAFwk;
32 using namespace OHOS::AppExecFwk;
33 using namespace OHOS::ExternalDeviceManager;
34 
35 enum {
36     ERR_DRV_PKG_MGR_ERROR = 1,
37 };
38 
39 struct BundleInfoNames {
40     string bundleName;
41     string abilityName;
42 };
43 
44 class DriverPkgManager {
45     DECLARE_SINGLE_INSTANCE_BASE(DriverPkgManager);
46 
47 public:
48     void PrintTest();
49     /**
50      * @brief Called at first before Monitor DriverExtension Package.
51      * @param bundleName Indicates the bundle name of the application.
52      * @param launcherShortcutInfo List of LauncherShortcutInfo objects if obtained.
53      * @return Returns true if the function is successfully called; returns false otherwise.
54      */
55     int32_t Init();
56     shared_ptr<BundleInfoNames> QueryMatchDriver(shared_ptr<DeviceInfo> devInfo);
57     int32_t RegisterOnBundleUpdate(PCALLBACKFUN pFun);
58     int32_t UnRegisterOnBundleUpdate();
59     ~DriverPkgManager();
60 private:
61     shared_ptr<BundleMonitor> bundleMonitor_ = nullptr;
62     sptr<DrvBundleStateCallback> bundleStateCallback_ = nullptr;
63     BundleInfoNames bundleInfoName_;
64 
65     int32_t RegisterCallback(const sptr<IBundleStatusCallback> &callback);
66     int32_t UnRegisterCallback();
67     DriverPkgManager();
68 };
69 } // namespace ExternalDeviceManager
70 } // namespace OHOS
71 #endif // DRIVER_PKG_MANAGER_H