1 /* 2 * Copyright (C) 2025 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 #include "accessibility_notification_helper.h" 17 #include "accessible_ability_manager_service.h" 18 #include "magnification_window_proxy.h" 19 20 namespace OHOS { 21 namespace Accessibility { 22 23 namespace { 24 const std::string INGORE_REPEAT_CLICK_KEY = "ignore_repeat_click_switch"; 25 const std::string IGNORE_REPEAT_CLICK_NOTIFICATION = "ignore_repeat_click_notification"; 26 } // namespace 27 28 CancelNotification()29void IgnoreRepeatClickNotification::CancelNotification() 30 { 31 if (MagnificationWindowProxy::GetInstance()) { 32 MagnificationWindowProxy::GetInstance()->CancelNotification(); 33 } 34 } 35 IsSendIgnoreRepeatClickNotification()36bool IgnoreRepeatClickNotification::IsSendIgnoreRepeatClickNotification() 37 { 38 auto accountData = Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 39 if (!accountData) { 40 return true; 41 } 42 bool notificationState = true; 43 bool ignoreRepeatClickState = false; 44 if (accountData->GetConfig() && accountData->GetConfig()->GetDbHandle()) { 45 notificationState = 46 accountData->GetConfig()->GetDbHandle()->GetBoolValue(IGNORE_REPEAT_CLICK_NOTIFICATION, true); 47 ignoreRepeatClickState = 48 accountData->GetConfig()->GetDbHandle()->GetBoolValue(INGORE_REPEAT_CLICK_KEY, false); 49 } 50 return ignoreRepeatClickState && notificationState; 51 } 52 PublishIgnoreRepeatClickReminder()53int32_t IgnoreRepeatClickNotification::PublishIgnoreRepeatClickReminder() 54 { 55 if (!IsSendIgnoreRepeatClickNotification()) { 56 return 0; 57 } 58 if (MagnificationWindowProxy::GetInstance()) { 59 return MagnificationWindowProxy::GetInstance()->PublishIgnoreRepeatClickReminder(); 60 } 61 return -1; 62 } 63 RegisterTimers(uint64_t beginTime)64int32_t IgnoreRepeatClickNotification::RegisterTimers(uint64_t beginTime) 65 { 66 if (!IsSendIgnoreRepeatClickNotification()) { 67 return 0; 68 } 69 if (MagnificationWindowProxy::GetInstance()) { 70 return MagnificationWindowProxy::GetInstance()->RegisterTimers(beginTime); 71 } 72 return -1; 73 } 74 DestoryTimers()75void IgnoreRepeatClickNotification::DestoryTimers() 76 { 77 if (MagnificationWindowProxy::GetInstance()) { 78 MagnificationWindowProxy::GetInstance()->DestoryTimers(); 79 } 80 } 81 GetWallTimeMs()82int64_t IgnoreRepeatClickNotification::GetWallTimeMs() 83 { 84 if (MagnificationWindowProxy::GetInstance()) { 85 return MagnificationWindowProxy::GetInstance()->GetWallTimeMs(); 86 } 87 return 0; 88 } 89 } // namespace Accessibility 90 } // namespace OHOS