1 /*
2  * Copyright (c) 2024-2024 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 BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_CLONE_BUNDLE_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_CLONE_BUNDLE_H
18 
19 #include "notification_clone_template.h"
20 
21 #include "ffrt.h"
22 #include "notification_bundle_option.h"
23 #include "notification_clone_bundle_info.h"
24 
25 namespace OHOS {
26 namespace Notification {
27 class NotificationCloneBundle final : public NotificationCloneTemplate {
28 public:
29     NotificationCloneBundle();
30     ~NotificationCloneBundle() override;
31     static std::shared_ptr<NotificationCloneBundle> GetInstance();
32     ErrCode OnBackup(nlohmann::json &jsonObject) override;
33     void OnRestore(const nlohmann::json &jsonObject) override;
34     void OnBundleDataAdd(const sptr<NotificationBundleOption> &bundleOption);
35     void OnBundleDataUpdate(const sptr<NotificationBundleOption> &bundleOption);
36     void HandleBundleEvent(const std::string bundleName, int32_t appIndex, int32_t uid);
37     void OnUserSwitch(int32_t userId) override;
38 private:
39     std::vector<NotificationCloneBundleInfo> bundlesInfo_;
40     std::shared_ptr<ffrt::queue> cloneBundleQueue_ = nullptr;
41     ffrt::mutex lock_;
42 };
43 } // namespace Notification
44 } // namespace OHOS
45 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_CLONE_BUNDLE_H
46