• 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 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     static constexpr int DB_CONNECT_MAX_WAIT_TIME = 10;
42     std::shared_ptr<DataShare::DataShareHelper> CreateOpKeyHelper(int waitTime);
43     std::shared_ptr<DataShare::DataShareHelper> CreateSimHelper();
44     std::shared_ptr<DataShare::DataShareHelper> CreatePdpHelper();
45     std::shared_ptr<DataShare::DataShareHelper> CreateSimHelper(const int waitTime);
46     bool IsDataShareError();
47     void ResetDataShareError();
48 
49 private:
50     std::shared_ptr<DataShare::DataShareHelper> CreateDataHelper(const std::string &strUri, const std::string &extUri,
51         const int waitTime = 2);
52     std::mutex lock_;
53     bool isOpkeyDbError_ = false;
54 };
55 }  // namespace Telephony
56 }  // namespace OHOS
57 #endif  // OHOS_TELEPHONY_DATA_HELPER_H