1 /* 2 * Copyright (C) 2021 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 17 #pragma once 18 19 #include <cstdint> 20 #include <string> 21 22 #include <binder/Parcelable.h> 23 #include <utils/Errors.h> 24 #include <utils/String16.h> 25 26 namespace android { 27 namespace aidl { 28 namespace tests { 29 30 class BadParcelable : public Parcelable { 31 public: 32 BadParcelable() = default; 33 BadParcelable(bool bad, const std::string& name, int32_t number); 34 virtual ~BadParcelable() = default; 35 36 status_t writeToParcel(Parcel* parcel) const override; 37 status_t readFromParcel(const Parcel* parcel) override; 38 39 std::string toString() const; 40 41 friend bool operator==(const BadParcelable& lhs, const BadParcelable& rhs) { 42 return (lhs.bad_ == rhs.bad_) && (lhs.name_ == rhs.name_) && (lhs.number_ == rhs.number_); 43 } 44 friend bool operator!=(const BadParcelable& lhs, const BadParcelable& rhs) { 45 return !(lhs == rhs); 46 } 47 48 private: 49 bool bad_; 50 String16 name_; 51 int32_t number_ = 0; 52 }; // class BadParcelable 53 54 } // namespace tests 55 } // namespace aidl 56 } // namespace android 57