1 /* 2 * Copyright (C) 2015 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 package android.car.hardware.hvac; 18 19 import android.car.hardware.CarPropertyValue; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 23 /** @hide */ 24 public class CarHvacEvent implements Parcelable { 25 public static final int HVAC_EVENT_PROPERTY_CHANGE = 0; 26 public static final int HVAC_EVENT_ERROR = 1; 27 28 /** 29 * EventType of this message 30 */ 31 private final int mEventType; 32 private final CarPropertyValue<?> mCarPropertyValue; 33 34 // Getters. 35 36 /** 37 * @return EventType field 38 */ getEventType()39 public int getEventType() { return mEventType; } 40 41 /** 42 * Returns {@link CarPropertyValue} associated with this event. 43 */ getCarPropertyValue()44 public CarPropertyValue<?> getCarPropertyValue() { return mCarPropertyValue; } 45 46 @Override describeContents()47 public int describeContents() { 48 return 0; 49 } 50 51 @Override writeToParcel(Parcel dest, int flags)52 public void writeToParcel(Parcel dest, int flags) { 53 dest.writeInt(mEventType); 54 dest.writeParcelable(mCarPropertyValue, flags); 55 } 56 57 public static final Parcelable.Creator<CarHvacEvent> CREATOR 58 = new Parcelable.Creator<CarHvacEvent>() { 59 public CarHvacEvent createFromParcel(Parcel in) { 60 return new CarHvacEvent(in); 61 } 62 63 public CarHvacEvent[] newArray(int size) { 64 return new CarHvacEvent[size]; 65 } 66 }; 67 68 /** 69 * Constructor for {@link CarHvacEvent}. 70 */ CarHvacEvent(int eventType, CarPropertyValue<?> carHvacProperty)71 public CarHvacEvent(int eventType, CarPropertyValue<?> carHvacProperty) { 72 mEventType = eventType; 73 mCarPropertyValue = carHvacProperty; 74 } 75 CarHvacEvent(Parcel in)76 private CarHvacEvent(Parcel in) { 77 mEventType = in.readInt(); 78 mCarPropertyValue = in.readParcelable(CarPropertyValue.class.getClassLoader()); 79 } 80 81 @Override toString()82 public String toString() { 83 return "CarHvacEvent{" + 84 "mEventType=" + mEventType + 85 ", mCarPropertyValue=" + mCarPropertyValue + 86 '}'; 87 } 88 } 89