• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_INTELLIGENT_EXPERIENCE = "intelligent_experience";
31 constexpr const char *KEY_FOCUS_MODE_CALL_MESSAGE_POLICY = "focus_mode_call_message_policy";
32 constexpr const char *KEY_FOCUS_MODE_REPEAT_CALLERS_ENABLE = "focus_mode_repeate_callers_enable";
33 constexpr const char *KEY_INTELLIGENT_SCENE_DATA = "intelligent_scene_data";
34 constexpr const char *KEY_INTELLIGENT_URI = "intelligent_uri";
35 } // namespace
36 
37 class AdvancedDatashareHelper : DelayedSingleton<AdvancedDatashareHelper> {
38 public:
39     AdvancedDatashareHelper();
40     ~AdvancedDatashareHelper() = default;
41     bool Query(Uri &uri, const std::string &key, std::string &value);
42     bool isRepeatCall(const std::string &phoneNumber);
43     ErrCode QueryContact(Uri &uri, const std::string &phoneNumber,
44         const std::string &policy, const std::string &profileId, const std::string isSupportIntelligentScene);
45     std::string GetFocusModeEnableUri(const int32_t &userId) const;
46     std::string GetFocusModeProfileUri(const int32_t &userId) const;
47     std::string GetIntelligentExperienceUri(const int32_t &userId) const;
48     std::string GetFocusModeCallPolicyUri(const int32_t &userId) const;
49     std::string GetFocusModeRepeatCallUri(const int32_t &userId) const;
50     std::string GetIntelligentUri();
51     std::string GetUnifiedGroupEnableUri() const;
52     static void SetIsDataShareReady(bool isDataShareReady);
53 
54 private:
55     enum ContactPolicy {
56         ALLOW_FAVORITE_CONTACTS = 4,
57         ALLOW_SPECIFIED_CONTACTS = 5,
58         FORBID_SPECIFIED_CONTACTS = 6,
59     };
60     std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper();
61     std::shared_ptr<DataShare::DataShareHelper> CreateContactDataShareHelper(std::string uri);
62     std::shared_ptr<DataShare::DataShareHelper> CreateIntelligentDataShareHelper(std::string uri);
63     std::shared_ptr<DataShare::DataShareResultSet> GetContactResultSet(Uri &uri, const std::string &phoneNumber,
64         const std::string &policy, const std::string &profileId, const std::string isSupportIntelligentScene);
65     bool dealWithContactResult(std::shared_ptr<DataShare::DataShareResultSet> resultSet, const std::string &policy);
66     std::string GetIntelligentData(const std::string &uri, const std::string &key);
67 private:
68     static bool isDataShareReady_;
69 };
70 } // namespace Notification
71 } // namespace OHOS
72 #endif // NOTIFICATION_ADVANCED_DATASHAER_HELPER_H
73