1 /* 2 * Copyright (c) 2021-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_DISTURB_H 17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_CLONE_DISTURB_H 18 19 #include "notification_clone_template.h" 20 21 #include "ffrt.h" 22 #include "notification_bundle_option.h" 23 #include "notification_do_not_disturb_profile.h" 24 25 namespace OHOS { 26 namespace Notification { 27 class NotificationCloneDisturb final : public NotificationCloneTemplate { 28 public: 29 NotificationCloneDisturb(); 30 ~NotificationCloneDisturb() override; 31 static std::shared_ptr<NotificationCloneDisturb> GetInstance(); 32 ErrCode OnBackup(nlohmann::json &jsonObject) override; 33 void OnRestore(const nlohmann::json &jsonObject) override; 34 void OnRestoreStart(const std::string bundleName, int32_t appIndex, int32_t userId, int32_t uid) override; 35 int32_t GetBundleUid(const std::string bundleName, int32_t userId, int32_t appIndex); 36 void GetProfileUid(int32_t userId, std::map<std::string, int32_t>& uidMap, 37 std::vector<NotificationBundleOption> trustList, std::vector<NotificationBundleOption>& exitBunldleList, 38 std::vector<NotificationBundleOption>& notExitBunldleList); 39 void CheckBundleInfo(std::vector<NotificationBundleOption>& trustList, 40 std::vector<NotificationBundleOption>& bundleList, const NotificationBundleOption& bundle); 41 int32_t GetActiveUserId(); 42 void OnUserSwitch(int32_t userId) override; 43 44 private: 45 std::atomic<int32_t> userId_ = -1; 46 std::vector<sptr<NotificationDoNotDisturbProfile>> profiles_; 47 std::shared_ptr<ffrt::queue> cloneDisturbQueue_ = nullptr; 48 }; 49 } // namespace Notification 50 } // namespace OHOS 51 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_CLONE_DISTURB_H 52