1 /*
2  * Copyright (c) 2022-2023 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 #include "usb_device_id.h"
17 #include "edm_log.h"
18 #include "parcel_macro.h"
19 
20 namespace OHOS {
21 namespace EDM {
Marshalling(MessageParcel & parcel) const22 bool UsbDeviceId::Marshalling(MessageParcel &parcel) const
23 {
24     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, vendorId_);
25     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, productId_);
26     return true;
27 }
28 
Unmarshalling(MessageParcel & parcel,UsbDeviceId & usbDeviceId)29 bool UsbDeviceId::Unmarshalling(MessageParcel &parcel, UsbDeviceId &usbDeviceId)
30 {
31     int32_t vendorId = parcel.ReadInt32();
32     int32_t productId = parcel.ReadInt32();
33     usbDeviceId.SetVendorId(vendorId);
34     usbDeviceId.SetProductId(productId);
35     return true;
36 }
37 
SetVendorId(int32_t vendorId)38 void UsbDeviceId::SetVendorId(int32_t vendorId)
39 {
40     vendorId_ = vendorId;
41 }
42 
SetProductId(int32_t productId)43 void UsbDeviceId::SetProductId(int32_t productId)
44 {
45     productId_ = productId;
46 }
47 
GetVendorId() const48 int32_t UsbDeviceId::GetVendorId() const
49 {
50     return vendorId_;
51 }
52 
GetProductId() const53 int32_t UsbDeviceId::GetProductId() const
54 {
55     return productId_;
56 }
57 } // namespace EDM
58 } // namespace OHOS
59