• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 #include "cellular_data_airplane_observer.h"
17 
18 #include "cellular_data_constant.h"
19 #include "cellular_data_event_code.h"
20 #include "cellular_data_settings_rdb_helper.h"
21 #include "core_manager_inner.h"
22 #include "telephony_log_wrapper.h"
23 
24 namespace OHOS {
25 namespace Telephony {
26 
OnChange()27 void CellularDataAirplaneObserver::OnChange()
28 {
29     std::shared_ptr<CellularDataSettingsRdbHelper> settingHelper = CellularDataSettingsRdbHelper::GetInstance();
30     if (settingHelper == nullptr) {
31         return;
32     }
33     Uri uri(CELLULAR_DATA_AIRPLANE_MODE_URI);
34     int value = 0;
35     if (settingHelper->GetValue(uri, CELLULAR_DATA_COLUMN_AIRPLANE, value) != TELEPHONY_ERR_SUCCESS) {
36         TELEPHONY_LOGE("GetValue failed!");
37         return;
38     }
39     isAirplaneModeOn_ = value;
40     TELEPHONY_LOGI("airplane switch is %{public}d", value);
41 }
42 
IsAirplaneModeOn()43 bool CellularDataAirplaneObserver::IsAirplaneModeOn()
44 {
45     return isAirplaneModeOn_;
46 }
47 } // namespace Telephony
48 } // namespace OHOS