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 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 DVB device. 25 * Not for third-party developers. 26 * 27 * @hide 28 */ 29public final class DvbDeviceInfo implements Parcelable { 30 static final String TAG = "DvbDeviceInfo"; 31 32 public static final Parcelable.Creator<DvbDeviceInfo> CREATOR = 33 new Parcelable.Creator<DvbDeviceInfo>() { 34 @Override 35 public DvbDeviceInfo createFromParcel(Parcel source) { 36 try { 37 return new DvbDeviceInfo(source); 38 } catch (Exception e) { 39 Log.e(TAG, "Exception creating DvbDeviceInfo from parcel", e); 40 return null; 41 } 42 } 43 44 @Override 45 public DvbDeviceInfo[] newArray(int size) { 46 return new DvbDeviceInfo[size]; 47 } 48 }; 49 50 private final int mAdapterId; 51 private final int mDeviceId; 52 53 private DvbDeviceInfo(Parcel source) { 54 mAdapterId = source.readInt(); 55 mDeviceId = source.readInt(); 56 } 57 58 /** 59 * Constructs a new {@link DvbDeviceInfo} with the given adapter ID and device ID. 60 */ 61 public DvbDeviceInfo(int adapterId, int deviceId) { 62 mAdapterId = adapterId; 63 mDeviceId = deviceId; 64 } 65 66 /** 67 * Returns the adapter ID of DVB device, in terms of enumerating the DVB device adapters 68 * installed in the system. The adapter ID counts from zero. 69 */ 70 public int getAdapterId() { 71 return mAdapterId; 72 } 73 74 /** 75 * Returns the device ID of DVB device, in terms of enumerating the DVB devices attached to 76 * the same device adapter. The device ID counts from zero. 77 */ 78 public int getDeviceId() { 79 return mDeviceId; 80 } 81 82 // Parcelable 83 @Override 84 public int describeContents() { 85 return 0; 86 } 87 88 @Override 89 public void writeToParcel(Parcel dest, int flags) { 90 dest.writeInt(mAdapterId); 91 dest.writeInt(mDeviceId); 92 } 93} 94