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_OBSERVER_PROXY_H
17 #define OHOS_BLUETOOTH_STANDARD_AVRCP_CT_OBSERVER_PROXY_H
18 
19 #include "iremote_proxy.h"
20 #include "i_bluetooth_host.h"
21 #include "i_bluetooth_avrcp_ct_observer.h"
22 
23 namespace OHOS {
24 namespace Bluetooth {
25 class BluetoothAvrcpCtObserverProxy : public IRemoteProxy<IBluetoothAvrcpCtObserver> {
26 public:
BluetoothAvrcpCtObserverProxy(const sptr<IRemoteObject> & impl)27     explicit BluetoothAvrcpCtObserverProxy(const sptr<IRemoteObject> &impl)
28         : IRemoteProxy<IBluetoothAvrcpCtObserver>(impl) {};
~BluetoothAvrcpCtObserverProxy()29     ~BluetoothAvrcpCtObserverProxy() {};
30 
31     void OnConnectionStateChanged(const RawAddress &rawAddr, int state, int cause) override;
32     void OnPressButton(const RawAddress &rawAddr, uint8_t button, int result) override;
33     void OnReleaseButton(const RawAddress &rawAddr, uint8_t button,  int result) override;
34     void OnSetBrowsedPlayer(const RawAddress &rawAddr, uint16_t uidCounter,
35         uint32_t numberOfItems, const std::vector<std::string> &folderNames, int result, int detail) override;
36     void OnGetCapabilities(const RawAddress &rawAddr, const std::vector<uint32_t> &companies,
37         const std::vector<uint8_t> &events, int result) override;
38     void OnGetPlayerAppSettingAttributes(
39         const RawAddress &rawAddr, std::vector<uint8_t> attributes, int result) override;
40     void OnGetPlayerAppSettingValues(const RawAddress &rawAddr,
41         int attribute, const std::vector<uint8_t> &values, int result) override;
42     void OnGetPlayerAppSettingCurrentValue(
43         const RawAddress &rawAddr, const std::vector<uint8_t> attributes,
44             const std::vector<uint8_t> &values, int result) override;
45     void OnSetPlayerAppSettingCurrentValue(const RawAddress &rawAddr, int result) override;
46     void OnGetPlayerAppSettingAttributeText(const RawAddress &rawAddr,
47         const std::vector<uint8_t> attribtues, const std::vector<std::string> &attributeName, int result) override;
48     void OnGetPlayerAppSettingValueText(const RawAddress &rawAddr,
49         const std::vector<uint8_t> &values, const std::vector<std::string> &valueName, int result) override;
50     void OnGetElementAttributes(const RawAddress &rawAddr,
51         const std::vector<uint32_t> &attribtues, const std::vector<std::string> &valueName, int result) override;
52     void OnGetPlayStatus(const RawAddress &rawAddr,
53         uint32_t songLength, uint32_t songPosition, uint8_t playStatus, int result) override;
54     void OnPlayItem(const RawAddress &rawAddr, int status, int result) override;
55     void OnGetTotalNumberOfItems(const RawAddress &rawAddr, uint16_t uidCounter, uint32_t numOfItems,
56         int result, int detail) override;
57     void OnGetItemAttributes(const RawAddress &rawAddr,
58         const std::vector<uint32_t> &attribtues, const std::vector<std::string> &values,
59             int result, int detail) override;
60     void OnSetAbsoluteVolume(const RawAddress &rawAddr, uint8_t volume, int result) override;
61     void OnPlaybackStatusChanged(const RawAddress &rawAddr, uint8_t playStatus, int result) override;
62     void OnTrackChanged(const RawAddress &rawAddr, uint64_t uid, int result) override;
63     void OnTrackReachedEnd(const RawAddress &rawAddr, int result) override;
64     void OnTrackReachedStart(const RawAddress &rawAddr, int result) override;
65     void OnPlaybackPosChanged(const RawAddress &rawAddr, uint32_t playbackPos, int result) override;
66     void OnPlayerAppSettingChanged(const RawAddress &rawAddr, const std::vector<uint8_t> &attributes,
67         const std::vector<uint8_t> &values, int result) override;
68     void OnNowPlayingContentChanged(const RawAddress &rawAddr, int result) override;
69     void OnAvailablePlayersChanged(const RawAddress &rawAddr, int result) override;
70     void OnAddressedPlayerChanged(
71         const RawAddress &rawAddr, uint16_t playerId, uint16_t uidCounter, int result) override;
72     void OnUidChanged(const RawAddress &rawAddr, uint16_t uidCounter, int result) override;
73     void OnVolumeChanged(const RawAddress &rawAddr, uint8_t volume, int result) override;
74     void OnGetMediaPlayers(const RawAddress &rawAddr, uint16_t uidCounter,
75         std::vector<BluetoothAvrcpMpItem> &items, int result, int detail) override;
76     void OnGetFolderItems(const RawAddress &rawAddr, uint16_t uidCounter, std::vector<BluetoothAvrcpMeItem> &items,
77         int result, int detail) override;
78 
79 private:
80     static inline BrokerDelegator<BluetoothAvrcpCtObserverProxy> delegator_;
81     ErrCode InnerTransact(BluetoothAvrcpCtObserverInterfaceCode interfaceCode,
82         MessageOption &flags, MessageParcel &data, MessageParcel &reply);
83     /**
84      * @brief Write the serializable data
85      * @param parcelableVector The communication data of IPC
86      * @param reply Serializable data
87      * @return true: Write the serializable data successfully; otherwise is not.
88      */
89     bool WriteParcelableInt32Vector(const std::vector<int32_t> &parcelableVector, Parcel &reply);
90 
91     /**
92      * @brief Write the serializable data
93      * @param parcelableVector The communication data of IPC
94      * @param reply Serializable data
95      * @return true: Write the serializable data successfully; otherwise is not.
96      */
97     bool WriteParcelableUint32Vector(const std::vector<uint32_t> &parcelableVector, Parcel &reply);
98 
99     /**
100      * @brief Write the serializable data
101      * @param parcelableVector The communication data of IPC
102      * @param reply Serializable data
103      * @return true: Write the serializable data successfully; otherwise is not.
104      */
105     bool WriteParcelableStringVector(const std::vector<std::string> &parcelableVector, Parcel &reply);
106 };
107 }  // namespace Bluetooth
108 }  // namespace OHOS
109 #endif  // OHOS_BLUETOOTH_STANDARD_AVRCP_CT_OBSERVER_PROXY_H