• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-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 #include "usb_ddk_service_mock.h"
16 
17 namespace OHOS {
18 namespace USB {
19 using namespace OHOS;
20 using namespace OHOS::HDI;
21 using namespace OHOS::HDI::Usb::Ddk::V1_1;
22 constexpr int32_t DEV_ADDR_INTERFACE_ERR = 9;
23 constexpr uint64_t BUS_NUM_OK = 6;
24 constexpr int32_t SHIFT_32 = 16;
25 std::vector<uint8_t> g_configDescBuf {
26     9, 2, 59, 0, 2, 1, 0, 160, 250, 9, 4, 0, 0, 1, 3, 1, 1, 0, 9, 33, 17, 1, 0, 1, 34, 67, 0, 7, 5, 129, 3, 8, 0, 1, 9,
27     4, 1, 0, 1, 3, 0, 0, 0, 9, 33, 17, 1, 0, 1, 34, 102, 0, 7, 5, 130, 3, 16, 0, 1
28 };
29 
GetConfigDescriptor(uint64_t deviceId,uint8_t configIndex,std::vector<uint8_t> & configDesc)30 int32_t UsbDdkServiceMock::GetConfigDescriptor(uint64_t deviceId, uint8_t configIndex, std::vector<uint8_t> &configDesc)
31 {
32     if (deviceId == ((BUS_NUM_OK << SHIFT_32) + DEV_ADDR_INTERFACE_ERR)) {
33         return HDF_DEV_ERR_NO_DEVICE;
34     }
35     configDesc = g_configDescBuf;
36     return HDF_SUCCESS;
37 }
38 }
39 }
40