• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 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.media.tv.tunerresourcemanager;
18 
19 import android.annotation.NonNull;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 import android.util.Log;
23 
24 /**
25  * Information required to request a Tuner Lnb.
26  *
27  * @hide
28  */
29 public final class TunerLnbRequest implements Parcelable {
30     static final String TAG = "TunerLnbRequest";
31 
32     public static final
33             @NonNull
34                 Parcelable.Creator<TunerLnbRequest> CREATOR =
35                 new Parcelable.Creator<TunerLnbRequest>() {
36                 @Override
37                 public TunerLnbRequest createFromParcel(Parcel source) {
38                     try {
39                         return new TunerLnbRequest(source);
40                     } catch (Exception e) {
41                         Log.e(TAG, "Exception creating TunerLnbRequest from parcel", e);
42                         return null;
43                     }
44                 }
45 
46                 @Override
47                 public TunerLnbRequest[] newArray(int size) {
48                     return new TunerLnbRequest[size];
49                 }
50             };
51 
52     /**
53      * Client id of the client that sends the request.
54      */
55     private final int mClientId;
56 
TunerLnbRequest(@onNull Parcel source)57     private TunerLnbRequest(@NonNull Parcel source) {
58         mClientId = source.readInt();
59     }
60 
61     /**
62      * Constructs a new {@link TunerLnbRequest} with the given parameters.
63      *
64      * @param clientId the id of the client.
65      */
TunerLnbRequest(int clientId)66     public TunerLnbRequest(int clientId) {
67         mClientId = clientId;
68     }
69 
70     /**
71      * Returns the id of the client
72      */
getClientId()73     public int getClientId() {
74         return mClientId;
75     }
76 
77     // Parcelable
78     @Override
describeContents()79     public int describeContents() {
80         return 0;
81     }
82 
83     @NonNull
84     @Override
toString()85     public String toString() {
86         StringBuilder b = new StringBuilder(128);
87         b.append("TunerLnbRequest {clientId=").append(mClientId);
88         b.append("}");
89         return b.toString();
90     }
91 
92     @Override
writeToParcel(@onNull Parcel dest, int flags)93     public void writeToParcel(@NonNull Parcel dest, int flags) {
94         dest.writeInt(mClientId);
95     }
96 }
97