1 /*
2  * Copyright (C) 2022 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_BLUETOOTH_STANDARD_AVRCP_CT_PROXY_H
17 #define OHOS_BLUETOOTH_STANDARD_AVRCP_CT_PROXY_H
18 
19 #include "iremote_proxy.h"
20 #include "i_bluetooth_host.h"
21 #include "i_bluetooth_avrcp_ct.h"
22 namespace OHOS {
23 namespace Bluetooth {
24 class BluetoothAvrcpCtProxy : public IRemoteProxy<IBluetoothAvrcpCt> {
25 public:
BluetoothAvrcpCtProxy(const sptr<IRemoteObject> & impl)26     explicit BluetoothAvrcpCtProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IBluetoothAvrcpCt>(impl) {};
~BluetoothAvrcpCtProxy()27     ~BluetoothAvrcpCtProxy() {};
28 
29     void RegisterObserver(const sptr<IBluetoothAvrcpCtObserver> &observer) override;
30     void UnregisterObserver(const sptr<IBluetoothAvrcpCtObserver> &observer) override;
31 
32     std::vector<RawAddress> GetConnectedDevices() override;
33     std::vector<RawAddress> GetDevicesByStates(const std::vector<int32_t> &states) override;
34     int32_t GetDeviceState(const RawAddress &device) override;
35     int32_t Connect(const RawAddress &device) override;
36     int32_t Disconnect(const RawAddress &device) override;
37     int32_t PressButton(const RawAddress &device, int32_t button) override;
38     int32_t ReleaseButton(const RawAddress &device, int32_t button) override;
39     int32_t GetUnitInfo(const RawAddress &device) override;
40     int32_t GetSubUnitInfo(const RawAddress &device) override;
41     int32_t GetSupportedCompanies(const RawAddress &device) override;
42     int32_t GetSupportedEvents(const RawAddress &device) override;
43     int32_t GetPlayerAppSettingAttributes(const RawAddress &device) override;
44     int32_t GetPlayerAppSettingValues(const RawAddress &device, int32_t attribute) override;
45     int32_t GetPlayerAppSettingCurrentValue(const RawAddress &device,
46         const std::vector<int32_t> &attributes) override;
47     int32_t SetPlayerAppSettingCurrentValue(const RawAddress &device,
48         const std::vector<int32_t> &attributes, const std::vector<int32_t> &values) override;
49     int32_t GetPlayerAppSettingAttributeText(const RawAddress &device,
50         const std::vector<int32_t> &attributes) override;
51     int32_t GetPlayerAppSettingValueText(const RawAddress &device, int32_t attributes,
52         const std::vector<int32_t> &values) override;
53     int32_t GetElementAttributes(const RawAddress &device,
54         const std::vector<int32_t> &attributes) override;
55     int32_t GetPlayStatus(const RawAddress &device) override;
56     int32_t PlayItem(const RawAddress &device, int32_t scope, int64_t uid, int32_t uidCounter) override;
57     int32_t GetFolderItems(const RawAddress &device, int32_t startItem, int32_t endItem,
58         const std::vector<int32_t> &attributes) override;
59     int32_t GetTotalNumberOfItems(const RawAddress &device, int32_t scope) override;
60     int32_t SetAbsoluteVolume(const RawAddress &device, int32_t volume) override;
61     int32_t EnableNotification(const RawAddress &device,
62         const std::vector<int32_t> &events, int32_t interval) override;
63     int32_t DisableNotification(const RawAddress &device, const std::vector<int32_t> &events) override;
64     int32_t GetItemAttributes(const RawAddress &device, int64_t uid, int32_t uidCounter,
65         const std::vector<int32_t> &attributes) override;
66     int32_t SetBrowsedPlayer(const RawAddress &device, int32_t playerId) override;
67     int32_t GetMeidaPlayerList(const RawAddress &device, int32_t startItem, int32_t endItem) override;
68 private:
69     static inline BrokerDelegator<BluetoothAvrcpCtProxy> delegator_;
70     ErrCode InnerTransact(
71         BluetoothAvrcpCtInterfaceCode interfaceCode, MessageOption &flags, MessageParcel &data, MessageParcel &reply);
72     /**
73      * @brief Write the serializable data
74      * @param parcelableVector The communication data of IPC
75      * @param reply Serializable data
76      * @return true: Write the serializable data successfully; otherwise is not.
77      */
78     bool WriteParcelableInt32Vector(const std::vector<int32_t> &parcelableVector, Parcel &reply);
79 };
80 }  // namespace Bluetooth
81 }  // namespace OHOS
82 #endif  // OHOS_BLUETOOTH_STANDARD_AVRCP_CT_PROXY_H