1 /* 2 * Copyright (c) 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 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_REMINDER_SWING_DECISION_CENTER_H 16 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_REMINDER_SWING_DECISION_CENTER_H 17 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED 18 19 #include <functional> 20 21 #include "refbase.h" 22 #include "singleton.h" 23 24 #include "ans_log_wrapper.h" 25 #include "ans_inner_errors.h" 26 #include "common_event_subscriber.h" 27 #include "common_event_manager.h" 28 #include "common_event_support.h" 29 #include "nlohmann/json.hpp" 30 #include "notification_config_parse.h" 31 #include "swing_callback_proxy.h" 32 #include "system_event_subscriber.h" 33 34 namespace OHOS { 35 namespace Notification { 36 using namespace std; 37 class ReminderSwingDecisionCenter { 38 public: 39 ReminderSwingDecisionCenter(); 40 ~ReminderSwingDecisionCenter(); 41 static ReminderSwingDecisionCenter &GetInstance(); 42 static sptr<ISwingCallBack> swingCallback_; 43 void ResetSwingCallbackProxy(); 44 ErrCode RegisterSwingCallback(const sptr<IRemoteObject> &swingCallback); 45 void UpdateCrossDeviceNotificationStatus(bool isEnable); 46 string GetSwingDeviceType(); 47 void OnScreenLock(); 48 void OnScreenUnlock(); 49 void OnUpdateDeviceStatus(const std::string &deviceType); 50 void OnSmartReminderStatusChanged(); 51 void SwingExecuteDecision(bool isScreenUnlockTrigger = false); 52 private: 53 void GetCcmSwingRemind(); 54 bool IsStatifySwingCrossDeviceStatus(); 55 void DisableSwingStatus(); 56 private: 57 static mutex swingMutex_; 58 string enableSwingDeviceType_; 59 string enableSwingDeviceStatus_; 60 bool isCrossDeviceNotificationEnable_ = false; 61 bool isSupportSwingSmartRemind_ = false; 62 bool isSwingExecuting_ = false; 63 bool isScreenUnlock_ = false; 64 sptr<IRemoteObject::DeathRecipient> swingRecipient_ = nullptr; 65 66 constexpr static inline const char* AFFTECED_BY = "affectedBy"; 67 constexpr static inline const char* SWING_FILTER = "swingEnableFilter"; 68 constexpr static inline const uint32_t UNLOCK_TRIGGER = 0; 69 constexpr static inline const uint32_t NONE_UNLOCK_TRIGGER = 1; 70 }; 71 72 class SwingCallbackRecipient : public IRemoteObject::DeathRecipient { 73 public: 74 SwingCallbackRecipient(); 75 virtual ~SwingCallbackRecipient(); 76 void OnRemoteDied(const wptr<IRemoteObject> &remote); 77 }; 78 } 79 } 80 #endif 81 #endif