• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024-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 TELEPHONY_DISTRIBUTED_COMMUNICATION_SOURCE_SWITCH_CONTROLLER_H
17 #define TELEPHONY_DISTRIBUTED_COMMUNICATION_SOURCE_SWITCH_CONTROLLER_H
18 
19 #ifdef ABILITY_BLUETOOTH_SUPPORT
20 #include "bluetooth_hfp_ag.h"
21 #endif
22 
23 #include "distributed_device_switch_controller.h"
24 
25 namespace OHOS {
26 namespace Telephony {
27 #ifdef ABILITY_BLUETOOTH_SUPPORT
28 class DcCallSourceHfpListener : public Bluetooth::HandsFreeAudioGatewayObserver {
29 public:
30     DcCallSourceHfpListener() = default;
31     ~DcCallSourceHfpListener() override = default;
32     void OnHfpStackChanged(const Bluetooth::BluetoothRemoteDevice &device, int32_t action) override;
33 
34 private:
35     BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(DcCallSourceHfpListener);
36     bool IsNeedSwitchToSource(const Bluetooth::BluetoothRemoteDevice &device, int32_t action);
37 };
38 #endif
39 
40 class DistributedSourceSwitchController : public DistributedDeviceSwitchController {
41 public:
42     DistributedSourceSwitchController() = default;
43     ~DistributedSourceSwitchController() override = default;
44     void OnDeviceOnline(const std::string &devId, const std::string &devName, AudioDeviceType devType) override;
45     void OnDeviceOffline(const std::string &devId, const std::string &devName, AudioDeviceType devType) override;
46     void OnDistributedAudioDeviceChange(const std::string &devId, const std::string &devName,
47         AudioDeviceType devType, int32_t devRole) override;
48     void OnRemoveSystemAbility() override;
49 
50     bool SwitchDevice(const std::string &devId, int32_t direction) override;
51 
52 private:
53     std::string GetDevAddress(const std::string &devId, const std::string &devName);
54 
55 private:
56 #ifdef ABILITY_BLUETOOTH_SUPPORT
57     std::shared_ptr<DcCallSourceHfpListener> hfpListener_{nullptr};
58 #endif
59 };
60 } // namespace Telephony
61 } // namespace OHOS
62 
63 #endif // TELEPHONY_DISTRIBUTED_COMMUNICATION_SOURCE_SWITCH_CONTROLLER_H
64