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 OnBundleDataAdd(const sptr<NotificationBundleOption> &bundleOption); 35 void OnBundleDataUpdate(const sptr<NotificationBundleOption> &bundleOption); 36 void HandlerBundleEvent(const std::string bundleName, int32_t appIndex, int32_t uid); 37 int32_t GetBundleUid(const std::string bundleName, int32_t userId, int32_t appIndex); 38 void GetProfileUid(int32_t userId, std::map<std::string, int32_t>& uidMap, 39 std::vector<NotificationBundleOption> trustList, std::vector<NotificationBundleOption>& exitBunldleList, 40 std::vector<NotificationBundleOption>& notExitBunldleList); 41 void CheckBundleInfo(std::vector<NotificationBundleOption>& trustList, 42 std::vector<NotificationBundleOption>& bundleList, const NotificationBundleOption& bundle); 43 int32_t GetActiveUserId(); 44 void OnUserSwitch(int32_t userId) override; 45 46 private: 47 std::atomic<int32_t> userId_ = -1; 48 std::vector<sptr<NotificationDoNotDisturbProfile>> profiles_; 49 std::shared_ptr<ffrt::queue> cloneDisturbQueue_ = nullptr; 50 }; 51 } // namespace Notification 52 } // namespace OHOS 53 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_CLONE_DISTURB_H 54