TvInputHardwareInfo.java revision d5cc4a281e7ce29d1e8687ff3394b57a3a549260
1/* 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.media.tv; 18 19import android.os.Parcel; 20import android.os.Parcelable; 21import android.util.Log; 22 23/** 24 * Simple container for information about TV input hardware. 25 * Not for third-party developers. 26 * 27 * @hide 28 */ 29public final class TvInputHardwareInfo implements Parcelable { 30 static final String TAG = "TvInputHardwareInfo"; 31 32 // Match hardware/libhardware/include/hardware/tv_input.h 33 public static final int TV_INPUT_TYPE_HDMI = 1; 34 public static final int TV_INPUT_TYPE_BUILT_IN_TUNER = 2; 35 public static final int TV_INPUT_TYPE_PASSTHROUGH = 3; 36 37 public static final Parcelable.Creator<TvInputHardwareInfo> CREATOR = 38 new Parcelable.Creator<TvInputHardwareInfo>() { 39 @Override 40 public TvInputHardwareInfo createFromParcel(Parcel source) { 41 try { 42 TvInputHardwareInfo info = new TvInputHardwareInfo(); 43 info.readFromParcel(source); 44 return info; 45 } catch (Exception e) { 46 Log.e(TAG, "Exception creating TvInputHardwareInfo from parcel", e); 47 return null; 48 } 49 } 50 51 @Override 52 public TvInputHardwareInfo[] newArray(int size) { 53 return new TvInputHardwareInfo[size]; 54 } 55 }; 56 57 private int mDeviceId; 58 private int mType; 59 // TODO: Add audio port & audio address for audio service. 60 // TODO: Add HDMI handle for HDMI service. 61 62 public TvInputHardwareInfo() { } 63 64 public TvInputHardwareInfo(int deviceId, int type) { 65 mDeviceId = deviceId; 66 mType = type; 67 } 68 69 public int getDeviceId() { 70 return mDeviceId; 71 } 72 73 public int getType() { 74 return mType; 75 } 76 77 // Parcelable 78 @Override 79 public int describeContents() { 80 return 0; 81 } 82 83 @Override 84 public void writeToParcel(Parcel dest, int flags) { 85 dest.writeInt(mDeviceId); 86 dest.writeInt(mType); 87 } 88 89 public void readFromParcel(Parcel source) { 90 mDeviceId = source.readInt(); 91 mType = source.readInt(); 92 } 93} 94