blob: 07cbdcceadbb28be6e9c3df1f70f327628f231b7 [file] [log] [blame]
Jinsuk Kim78d695d2014-05-13 16:36:15 +09001/*
2 * Copyright (C) 2014 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
17package android.hardware.hdmi;
18
Jinsuk Kim66d1eb22014-06-06 16:12:18 +090019import android.annotation.SystemApi;
Jinsuk Kim78d695d2014-05-13 16:36:15 +090020import android.os.Parcel;
21import android.os.Parcelable;
22
23/**
24 * A class that describes the HDMI port hotplug event.
Jinsuk Kim66d1eb22014-06-06 16:12:18 +090025 *
26 * @hide
Jinsuk Kim78d695d2014-05-13 16:36:15 +090027 */
Jinsuk Kim66d1eb22014-06-06 16:12:18 +090028@SystemApi
Jinsuk Kim78d695d2014-05-13 16:36:15 +090029public final class HdmiHotplugEvent implements Parcelable {
30
31 private final int mPort;
32 private final boolean mConnected;
33
34 /**
35 * Constructor.
36 *
37 * <p>Marked as hidden so only system can create the instance.
38 *
39 * @hide
40 */
41 public HdmiHotplugEvent(int port, boolean connected) {
42 mPort = port;
43 mConnected = connected;
44 }
45
46 /**
Yuncheol Heo2b0da5c2014-10-22 14:32:27 +090047 * Returns the port number for which the event occurred.
Jinsuk Kim78d695d2014-05-13 16:36:15 +090048 *
49 * @return port number
50 */
51 public int getPort() {
52 return mPort;
53 }
54
55 /**
Yuncheol Heo2b0da5c2014-10-22 14:32:27 +090056 * Returns the connection status associated with this event
Jinsuk Kim78d695d2014-05-13 16:36:15 +090057 *
58 * @return true if the device gets connected; otherwise false
59 */
60 public boolean isConnected() {
61 return mConnected;
62 }
63
64 /**
Yuncheol Heo2b0da5c2014-10-22 14:32:27 +090065 * Describes the kinds of special objects contained in this Parcelable's
Jinsuk Kim78d695d2014-05-13 16:36:15 +090066 * marshalled representation.
67 */
68 @Override
69 public int describeContents() {
70 return 0;
71 }
72
73 /**
Yuncheol Heo2b0da5c2014-10-22 14:32:27 +090074 * Flattens this object in to a Parcel.
Jinsuk Kim78d695d2014-05-13 16:36:15 +090075 *
76 * @param dest The Parcel in which the object should be written.
77 * @param flags Additional flags about how the object should be written.
78 * May be 0 or {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}.
79 */
80 @Override
81 public void writeToParcel(Parcel dest, int flags) {
82 dest.writeInt(mPort);
83 dest.writeByte((byte) (mConnected ? 1 : 0));
84 }
85
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070086 public static final @android.annotation.NonNull Parcelable.Creator<HdmiHotplugEvent> CREATOR
Jinsuk Kim78d695d2014-05-13 16:36:15 +090087 = new Parcelable.Creator<HdmiHotplugEvent>() {
88 /**
Yuncheol Heo2b0da5c2014-10-22 14:32:27 +090089 * Rebuilds a {@link HdmiHotplugEvent} previously stored with
Jinsuk Kim78d695d2014-05-13 16:36:15 +090090 * {@link Parcelable#writeToParcel(Parcel, int)}.
91 *
92 * @param p {@link HdmiHotplugEvent} object to read the Rating from
93 * @return a new {@link HdmiHotplugEvent} created from the data in the parcel
94 */
Yuncheol Heo2b0da5c2014-10-22 14:32:27 +090095 @Override
Jinsuk Kim78d695d2014-05-13 16:36:15 +090096 public HdmiHotplugEvent createFromParcel(Parcel p) {
97 int port = p.readInt();
98 boolean connected = p.readByte() == 1;
99 return new HdmiHotplugEvent(port, connected);
100 }
Yuncheol Heo2b0da5c2014-10-22 14:32:27 +0900101 @Override
Jinsuk Kim78d695d2014-05-13 16:36:15 +0900102 public HdmiHotplugEvent[] newArray(int size) {
103 return new HdmiHotplugEvent[size];
104 }
105 };
106}