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 OHOS_TELEPHONY_DATA_HELPER_H
17 #define OHOS_TELEPHONY_DATA_HELPER_H
18 
19 #include <mutex>
20 #include <singleton.h>
21 #include "datashare_helper.h"
22 #include "iservice_registry.h"
23 #include "system_ability_definition.h"
24 #include "uri.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 class TelephonyDataHelper : public DelayedSingleton<TelephonyDataHelper> {
29     DECLARE_DELAYED_SINGLETON(TelephonyDataHelper);
30 
31 public:
32     static constexpr const char *SIM_DB_URI =
33         "datashare:///com.ohos.telephonydataability/entry/sim/sim_info?Proxy=true";
34     static constexpr const char *SIM_URI = "datashare:///com.ohos.simability";
35     static constexpr const char *OPKEY_DB_URI =
36         "datashare:///com.ohos.telephonydataability/entry/opkey/opkey_info?Proxy=true";
37     static constexpr const char *OPKEY_URI = "datashare:///com.ohos.opkeyability";
38     static constexpr const char *PDP_DB_URI =
39         "datashare:///com.ohos.telephonydataability/entry/net/pdp_profile?Proxy=true";
40     static constexpr const char *PDP_URI = "datashare:///com.ohos.pdpprofileability";
41     std::shared_ptr<DataShare::DataShareHelper> CreateOpKeyHelper();
42     std::shared_ptr<DataShare::DataShareHelper> CreateSimHelper();
43     std::shared_ptr<DataShare::DataShareHelper> CreatePdpHelper();
44     std::shared_ptr<DataShare::DataShareHelper> CreateSimHelper(const int waitTime);
45     bool IsDataShareError();
46     void ResetDataShareError();
47 
48 private:
49     std::shared_ptr<DataShare::DataShareHelper> CreateDataHelper(const std::string &strUri, const std::string &extUri,
50         const int waitTime = 2);
51     std::mutex lock_;
52     bool mIsDataShareError = false;
53 };
54 }  // namespace Telephony
55 }  // namespace OHOS
56 #endif  // OHOS_TELEPHONY_DATA_HELPER_H