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 #ifndef HPAE_MANAGER_FUZZER_H 17 #define HPAE_MANAGER_FUZZER_H 18 19 #include "audio_service_hpae_callback.h" 20 #include "audio_info.h" 21 #include "hpae_manager.h" 22 class HpaeAudioServiceCallbackFuzzTest : public OHOS::AudioStandard::AudioServiceHpaeCallback { 23 public: ~HpaeAudioServiceCallbackFuzzTest()24 ~HpaeAudioServiceCallbackFuzzTest() override {} 25 OnOpenAudioPortCb(int32_t portId)26 void OnOpenAudioPortCb(int32_t portId) override 27 { 28 portId_ = portId; 29 } 30 OnCloseAudioPortCb(int32_t result)31 void OnCloseAudioPortCb(int32_t result) override 32 { 33 closeAudioPortResult_ = result; 34 } 35 OnReloadAudioPortCb(int32_t portId)36 void OnReloadAudioPortCb(int32_t portId) override 37 { 38 portId_ = portId; 39 } 40 OnSetSinkMuteCb(int32_t result)41 void OnSetSinkMuteCb(int32_t result) override 42 { 43 setSinkMuteResult_ = result; 44 } 45 OnGetAllSinkInputsCb(int32_t result,std::vector<OHOS::AudioStandard::SinkInput> & sinkInputs)46 void OnGetAllSinkInputsCb(int32_t result, std::vector<OHOS::AudioStandard::SinkInput> &sinkInputs) override 47 { 48 getAllSinkInputsResult_ = result; 49 sinkInputs_ = sinkInputs; 50 } 51 OnGetAllSourceOutputsCb(int32_t result,std::vector<OHOS::AudioStandard::SourceOutput> & sourceOutputs)52 void OnGetAllSourceOutputsCb(int32_t result, 53 std::vector<OHOS::AudioStandard::SourceOutput> &sourceOutputs) override 54 { 55 getAllSourceOutputsResult_ = result; 56 sourceOutputs_ = sourceOutputs; 57 } 58 OnGetAllSinksCb(int32_t result,std::vector<OHOS::AudioStandard::SinkInfo> & sinks)59 void OnGetAllSinksCb(int32_t result, std::vector<OHOS::AudioStandard::SinkInfo> &sinks) override 60 { 61 getAllSinksResult_ = result; 62 sinks_ = sinks; 63 } 64 OnMoveSinkInputByIndexOrNameCb(int32_t result)65 void OnMoveSinkInputByIndexOrNameCb(int32_t result) override 66 { 67 moveSinkInputByIndexOrNameResult_ = result; 68 } 69 OnMoveSourceOutputByIndexOrNameCb(int32_t result)70 void OnMoveSourceOutputByIndexOrNameCb(int32_t result) override 71 { 72 moveSourceOutputByIndexOrNameResult_ = result; 73 } 74 OnSetSourceOutputMuteCb(int32_t result)75 void OnSetSourceOutputMuteCb(int32_t result) override 76 { 77 setSourceOutputMuteResult_ = result; 78 } 79 OnGetAudioEffectPropertyCbV3(int32_t result)80 void OnGetAudioEffectPropertyCbV3(int32_t result) override 81 { 82 getAudioEffectPropertyResult_ = result; 83 } 84 OnGetAudioEffectPropertyCb(int32_t result)85 void OnGetAudioEffectPropertyCb(int32_t result) override 86 { 87 getAudioEffectPropertyResult_ = result; 88 } 89 OnGetAudioEnhancePropertyCbV3(int32_t result)90 void OnGetAudioEnhancePropertyCbV3(int32_t result) override 91 { 92 getAudioEnhancePropertyResult_ = result; 93 } 94 OnGetAudioEnhancePropertyCb(int32_t result)95 void OnGetAudioEnhancePropertyCb(int32_t result) override 96 { 97 getAudioEnhancePropertyResult_ = result; 98 } 99 HandleSourceAudioStreamRemoved(uint32_t sessionId)100 void HandleSourceAudioStreamRemoved(uint32_t sessionId) override {} 101 GetPortId()102 int32_t GetPortId() const noexcept 103 { 104 return portId_; 105 } 106 GetCloseAudioPortResult()107 int32_t GetCloseAudioPortResult() const noexcept 108 { 109 return closeAudioPortResult_; 110 } 111 GetSetSinkMuteResult()112 int32_t GetSetSinkMuteResult() const noexcept 113 { 114 return setSinkMuteResult_; 115 } 116 GetGetAllSinkInputsResult()117 int32_t GetGetAllSinkInputsResult() const noexcept 118 { 119 return getAllSinkInputsResult_; 120 } 121 GetGetAllSourceOutputsResult()122 int32_t GetGetAllSourceOutputsResult() const noexcept 123 { 124 return getAllSourceOutputsResult_; 125 } 126 GetGetAllSinksResult()127 int32_t GetGetAllSinksResult() const noexcept 128 { 129 return getAllSinksResult_; 130 } 131 GetMoveSinkInputByIndexOrNameResult()132 int32_t GetMoveSinkInputByIndexOrNameResult() const noexcept 133 { 134 return moveSinkInputByIndexOrNameResult_; 135 } 136 GetMoveSourceOutputByIndexOrNameResult()137 int32_t GetMoveSourceOutputByIndexOrNameResult() const noexcept 138 { 139 return moveSourceOutputByIndexOrNameResult_; 140 } 141 GetSetSourceOutputMuteResult()142 int32_t GetSetSourceOutputMuteResult() const noexcept 143 { 144 return setSourceOutputMuteResult_; 145 } 146 GetGetAudioEffectPropertyResult()147 int32_t GetGetAudioEffectPropertyResult() const noexcept 148 { 149 return getAudioEffectPropertyResult_; 150 } 151 GetGetAudioEnhancePropertyResult()152 int32_t GetGetAudioEnhancePropertyResult() const noexcept 153 { 154 return getAudioEnhancePropertyResult_; 155 } 156 GetSinkInputs()157 std::vector<OHOS::AudioStandard::SinkInput> GetSinkInputs() const noexcept 158 { 159 return sinkInputs_; 160 } 161 GetSourceOutputs()162 std::vector<OHOS::AudioStandard::SourceOutput> GetSourceOutputs() const noexcept 163 { 164 return sourceOutputs_; 165 } 166 GetSinks()167 std::vector<OHOS::AudioStandard::SinkInfo> GetSinks() const noexcept 168 { 169 return sinks_; 170 } 171 172 private: 173 int32_t portId_ = -1; 174 int32_t closeAudioPortResult_ = -1; 175 int32_t setSinkMuteResult_ = -1; 176 int32_t getAllSinkInputsResult_ = -1; 177 int32_t getAllSourceOutputsResult_ = -1; 178 int32_t getAllSinksResult_ = -1; 179 int32_t moveSinkInputByIndexOrNameResult_ = -1; 180 int32_t moveSourceOutputByIndexOrNameResult_ = -1; 181 int32_t setSourceOutputMuteResult_ = -1; 182 int32_t getAudioEffectPropertyResult_ = -1; 183 int32_t getAudioEnhancePropertyResult_ = -1; 184 std::vector<OHOS::AudioStandard::SinkInput> sinkInputs_; 185 std::vector<OHOS::AudioStandard::SourceOutput> sourceOutputs_; 186 std::vector<OHOS::AudioStandard::SinkInfo> sinks_; 187 }; 188 189 #endif // HPAE_MANAGER_FUZZER_H