• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 DISTRIBUTEDDATAMGR_UNINSTALLER_IMPL_H
17 #define DISTRIBUTEDDATAMGR_UNINSTALLER_IMPL_H
18 
19 #include "common_event_subscriber.h"
20 #include "kvstore_data_service.h"
21 #include "uninstaller.h"
22 
23 namespace OHOS::DistributedKv {
24 using UninstallEventCallback = std::function<void(const std::string &bundleName, int32_t userId, int32_t appIndex)>;
25 
26 class UninstallEventSubscriber : public EventFwk::CommonEventSubscriber {
27 public:
28     UninstallEventSubscriber(const EventFwk::CommonEventSubscribeInfo &info,
29         UninstallEventCallback callback);
30 
~UninstallEventSubscriber()31     ~UninstallEventSubscriber() {}
32     void OnReceiveEvent(const EventFwk::CommonEventData &event) override;
33 
34 private:
35     static constexpr const char *USER_ID = "userId";
36     static constexpr const char *SANDBOX_APP_INDEX = "sandbox_app_index";
37     UninstallEventCallback callback_;
38 };
39 class UninstallerImpl : public Uninstaller {
40 public:
41     ~UninstallerImpl();
42 
43     Status Init(KvStoreDataService *kvStoreDataService) override;
44 
45     void UnsubscribeEvent() override;
46 
47 private:
48     std::shared_ptr<UninstallEventSubscriber> subscriber_ {};
49 };
50 } // namespace OHOS::DistributedKv
51 #endif // DISTRIBUTEDDATAMGR_UNINSTALLER_IMPL_H
52