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 #include "network_set_manager.h"
16 
17 #include "accesstoken_kit.h"
18 #include "cloud_file_kit.h"
19 #include "datashare_errno.h"
20 #include "datashare_result_set.h"
21 #include "dfs_error.h"
22 #include "ipc_skeleton.h"
23 #include "iservice_registry.h"
24 #include "parameters.h"
25 #include "system_ability_definition.h"
26 #include "utils_log.h"
27 
28 namespace OHOS::FileManagement::CloudSync {
29 const std::string QUERY_URI = "datashareproxy://";
30 const std::string PHOTO_NET_CONT = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true";
31 const std::string SWITCH_STATUS_KEY = "useMobileNetworkData";
32 const std::string CLOUDDRIVE_KEY = "persist.kernel.bundle_name.clouddrive";
33 const std::string PHOTOS_BUNDLE_NAME = "com.ohos.photos";
34 const std::string BUNDLE_NAME_KEY = "key";
35 const std::string BUNDLE_NAME_VALUE = "value";
36 const std::int32_t MOCK_USER_ID = 1;
37 auto clouddriveBundleName = system::GetParameter(CLOUDDRIVE_KEY, "");
38 auto photoQueryUri = PHOTO_NET_CONT + "&key=photo_network_connection_status";
39 auto queryUri = QUERY_URI + clouddriveBundleName + "/cloud_sp?key=" + SWITCH_STATUS_KEY;
40 DataShare::CreateOptions options;
41 
QueryCellularConnect(int32_t userId,const std::string & bundleName)42 int32_t NetworkSetManager::QueryCellularConnect(int32_t userId, const std::string &bundleName)
43 {
44     return E_OK;
45 }
46 
QueryNetConnect(int32_t userId,const std::string & bundleName)47 int32_t NetworkSetManager::QueryNetConnect(int32_t userId, const std::string &bundleName)
48 {
49     return E_OK;
50 }
51 
GetCellularConnect(const std::string & bundleName,const int32_t userId)52 void NetworkSetManager::GetCellularConnect(const std::string &bundleName, const int32_t userId)
53 {
54 }
55 
GetNetConnect(const std::string & bundleName,const int32_t userId)56 void NetworkSetManager::GetNetConnect(const std::string &bundleName, const int32_t userId)
57 {
58 }
59 
GetConfigParams(const std::string & bundleName,int32_t userId)60 bool NetworkSetManager::GetConfigParams(const std::string &bundleName, int32_t userId)
61 {
62     return true;
63 }
64 
UnregisterObserver(const std::string & bundleName,const int32_t userId,const int32_t type)65 void NetworkSetManager::UnregisterObserver(const std::string &bundleName, const int32_t userId, const int32_t type)
66 {
67 }
68 
RegisterObserver(const std::string & bundleName,const int32_t userId,const int32_t type)69 void NetworkSetManager::RegisterObserver(const std::string &bundleName, const int32_t userId, const int32_t type)
70 {
71 }
72 
OnChange()73 void MobileNetworkObserver::OnChange()
74 {
75 }
76 
IsAllowCellularConnect(const std::string & bundleName,const int32_t userId)77 bool NetworkSetManager::IsAllowCellularConnect(const std::string &bundleName, const int32_t userId)
78 {
79     if (userId == MOCK_USER_ID) {
80         return true;
81     }
82     return false;
83 }
84 
IsAllowNetConnect(const std::string & bundleName,const int32_t userId)85 bool NetworkSetManager::IsAllowNetConnect(const std::string &bundleName, const int32_t userId)
86 {
87     if (userId == MOCK_USER_ID) {
88         return true;
89     }
90     return false;
91 }
92 
InitNetworkSetManager(const std::string & bundleName,const int32_t userId)93 void NetworkSetManager::InitNetworkSetManager(const std::string &bundleName, const int32_t userId)
94 {
95 }
96 
InitDataSyncManager(std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager)97 void NetworkSetManager::InitDataSyncManager(std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager)
98 {
99 }
100 
NetWorkChangeStopUploadTask()101 void NetworkSetManager::NetWorkChangeStopUploadTask()
102 {
103 }
104 }