1 /*
2 * Copyright (c) 2025 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 "mission/bluetooth_state_adapter.h"
17 #include "mission/dms_continue_condition_manager.h"
18 #include "dtbschedmgr_log.h"
19
20 namespace OHOS {
21 namespace DistributedSchedule {
22 namespace {
23 const std::string TAG = "BluetoothStateAdapter";
24 }
25
26 IMPLEMENT_SINGLE_INSTANCE(BluetoothStateAdapter);
27
IsBluetoothActive()28 bool BluetoothStateAdapter::IsBluetoothActive()
29 {
30 HILOGI("current BT state cache is: %{public}s; BLE state cache is: %{public}s", isBTActive_ ? "true" : "false",
31 isBLEActive_ ? "true" : "false");
32 return isBTActive_.load() || isBLEActive_.load();
33 }
34
UpdateBTState(bool isBTActive)35 void BluetoothStateAdapter::UpdateBTState(bool isBTActive)
36 {
37 HILOGI("update BT state: %{public}s", isBTActive ? "true" : "false");
38 isBTActive_.store(isBTActive);
39 DmsContinueConditionMgr::GetInstance().UpdateSystemStatus(SYS_EVENT_BLUETOOTH,
40 isBTActive_.load() || isBLEActive_.load());
41 }
42
UpdateBLEState(bool isBLEActive)43 void BluetoothStateAdapter::UpdateBLEState(bool isBLEActive)
44 {
45 HILOGI("update BLE state: %{public}s", isBLEActive ? "true" : "false");
46 isBLEActive_.store(isBLEActive);
47 DmsContinueConditionMgr::GetInstance().UpdateSystemStatus(SYS_EVENT_BLUETOOTH,
48 isBTActive_.load() || isBLEActive_.load());
49 }
50
51
52 } // namespace DistributedSchedule
53 } // namespace OHOS
54