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 16 #ifndef NOTIFICATION_ADVANCED_DATASHAER_HELPER_H 17 #define NOTIFICATION_ADVANCED_DATASHAER_HELPER_H 18 19 #include "datashare_helper.h" 20 #include "iremote_broker.h" 21 #include "singleton.h" 22 #include "system_ability_definition.h" 23 #include "uri.h" 24 25 namespace OHOS { 26 namespace Notification { 27 namespace { 28 constexpr const char *KEY_FOCUS_MODE_ENABLE = "focus_mode_enable"; 29 constexpr const char *KEY_FOCUS_MODE_PROFILE = "focus_mode_profile"; 30 constexpr const char *KEY_FOCUS_MODE_CALL_MESSAGE_POLICY = "focus_mode_call_message_policy"; 31 constexpr const char *KEY_FOCUS_MODE_REPEAT_CALLERS_ENABLE = "focus_mode_repeate_callers_enable"; 32 } // namespace 33 34 class AdvancedDatashareHelper : DelayedSingleton<AdvancedDatashareHelper> { 35 public: 36 AdvancedDatashareHelper(); 37 ~AdvancedDatashareHelper() = default; 38 bool Query(Uri &uri, const std::string &key, std::string &value); 39 bool isRepeatCall(const std::string &phoneNumber); 40 ErrCode QueryContact(Uri &uri, const std::string &phoneNumber, const std::string &policy); 41 std::string GetFocusModeEnableUri(const int32_t &userId) const; 42 std::string GetFocusModeProfileUri(const int32_t &userId) const; 43 std::string GetFocusModeCallPolicyUri(const int32_t &userId) const; 44 std::string GetFocusModeRepeatCallUri(const int32_t &userId) const; 45 std::string GetUnifiedGroupEnableUri() const; 46 47 private: 48 enum ContactPolicy { 49 ALLOW_FAVORITE_CONTACTS = 4, 50 ALLOW_SPECIFIED_CONTACTS = 5, 51 }; 52 std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper(); 53 std::shared_ptr<DataShare::DataShareHelper> CreateContactDataShareHelper(std::string uri); 54 bool dealWithContactResult(std::shared_ptr<DataShare::DataShareHelper> helper, 55 std::shared_ptr<DataShare::DataShareResultSet> resultSet, const std::string &policy); 56 }; 57 } // namespace Notification 58 } // namespace OHOS 59 #endif // NOTIFICATION_ADVANCED_DATASHAER_HELPER_H 60