1 /* 2 * Copyright (C) 2021 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 "input_channel.h" 17 #include "input_attribute.h" 18 #include "global.h" 19 20 namespace OHOS { 21 namespace MiscServices { 22 /*! Constructor 23 */ InputChannel()24 InputChannel::InputChannel() 25 { 26 } 27 28 /*! Destructor 29 */ ~InputChannel()30 InputChannel::~InputChannel() 31 { 32 } 33 34 /*! Write InputChannel to parcel 35 \param[out] parcel the data of InputChannel is written to this parcel returned to caller 36 \return ErrorCode::NO_ERROR 37 \return ErrorCode::ERROR_NULL_POINTER parcel is null 38 */ Marshalling(Parcel & parcel) const39 bool InputChannel::Marshalling(Parcel &parcel) const 40 { 41 parcel.ParseFrom(inputChannelParcel.GetData(), inputChannelParcel.GetDataSize()); 42 return NO_ERROR; 43 } 44 45 /*! Get InputChannel from parcel 46 \param parcel get the data of InputChannel from this parcel 47 \return ErrorCode::NO_ERROR 48 \return ErrorCode::ERROR_NULL_POINTER parcel is null 49 */ Unmarshalling(Parcel & parcel)50 InputChannel *InputChannel::Unmarshalling(Parcel &parcel) 51 { 52 auto inputChannel = new InputChannel(); 53 inputChannel->inputChannelParcel.RewindRead(0); 54 inputChannel->inputChannelParcel.ParseFrom(parcel.GetData(), parcel.GetDataSize()); 55 inputChannel->inputChannelParcel.RewindRead(0); 56 57 inputChannel->name = inputChannel->inputChannelParcel.ReadString16(); 58 inputChannel->inputChannelParcel.RewindRead(0); 59 return inputChannel; 60 } 61 } 62 } 63