1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #include "event.h" 17 18 #include <binder/Parcel.h> 19 #include <utils/String8.h> 20 #include <utils/String16.h> 21 22 using namespace com::android::car::keventreader; 23 KeypressEvent(const std::string source,uint32_t keycode,bool keydown)24KeypressEvent::KeypressEvent(const std::string source, uint32_t keycode, bool keydown) { 25 this->source = source; 26 this->keycode = keycode; 27 this->keydown = keydown; 28 } 29 writeToParcel(Parcel * parcel) const30status_t KeypressEvent::writeToParcel(Parcel* parcel) const { 31 String16 s16 = String16(source.c_str()); 32 parcel->writeString16(s16); 33 parcel->writeUint32(keycode); 34 parcel->writeBool(keydown); 35 36 return OK; 37 } 38 readFromParcel(const Parcel * parcel)39status_t KeypressEvent::readFromParcel(const Parcel* parcel) { 40 String16 s16 = parcel->readString16(); 41 source = std::string(String8(s16).c_str()); 42 keycode = parcel->readUint32(); 43 keydown = parcel->readBool(); 44 45 return OK; 46 } 47