• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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.tuner.frontend;
18 
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 import android.media.tv.tuner.frontend.FrontendSettings.Type;
22 import android.media.tv.tuner.frontend.FrontendStatus.FrontendStatusType;
23 import android.util.Range;
24 
25 import java.util.Arrays;
26 import java.util.Objects;
27 
28 /**
29  * This class is used to specify meta information of a frontend.
30  *
31  * @hide
32  */
33 @SystemApi
34 public class FrontendInfo {
35     private final int mId;
36     private final int mType;
37     private final Range<Integer> mFrequencyRange;
38     private final Range<Integer> mSymbolRateRange;
39     private final int mAcquireRange;
40     private final int mExclusiveGroupId;
41     private final int[] mStatusCaps;
42     private final FrontendCapabilities mFrontendCap;
43 
FrontendInfo(int id, int type, int minFrequency, int maxFrequency, int minSymbolRate, int maxSymbolRate, int acquireRange, int exclusiveGroupId, int[] statusCaps, FrontendCapabilities frontendCap)44     private FrontendInfo(int id, int type, int minFrequency, int maxFrequency, int minSymbolRate,
45             int maxSymbolRate, int acquireRange, int exclusiveGroupId, int[] statusCaps,
46             FrontendCapabilities frontendCap) {
47         mId = id;
48         mType = type;
49         // if max Frequency is negative, we set it as max value of the Integer.
50         if (maxFrequency < 0) {
51             maxFrequency = Integer.MAX_VALUE;
52         }
53         mFrequencyRange = new Range<>(minFrequency, maxFrequency);
54         mSymbolRateRange = new Range<>(minSymbolRate, maxSymbolRate);
55         mAcquireRange = acquireRange;
56         mExclusiveGroupId = exclusiveGroupId;
57         mStatusCaps = statusCaps;
58         mFrontendCap = frontendCap;
59     }
60 
61     /**
62      * Gets frontend ID.
63      *
64      * @return the frontend ID or {@link android.media.tv.tuner.Tuner#INVALID_FRONTEND_ID}
65      *         if invalid
66      */
getId()67     public int getId() {
68         return mId;
69     }
70     /**
71      * Gets frontend type.
72      */
73     @Type
getType()74     public int getType() {
75         return mType;
76     }
77 
78     /**
79      * Gets supported frequency range in Hz.
80      */
81     @NonNull
getFrequencyRange()82     public Range<Integer> getFrequencyRange() {
83         return mFrequencyRange;
84     }
85 
86     /**
87      * Gets symbol rate range in symbols per second.
88      */
89     @NonNull
getSymbolRateRange()90     public Range<Integer> getSymbolRateRange() {
91         return mSymbolRateRange;
92     }
93 
94     /**
95      * Gets acquire range in Hz.
96      *
97      * <p>The maximum frequency difference the frontend can detect.
98      */
getAcquireRange()99     public int getAcquireRange() {
100         return mAcquireRange;
101     }
102     /**
103      * Gets exclusive group ID.
104      *
105      * <p>Frontends with the same exclusive group ID indicates they can't function at same time. For
106      * instance, they share some hardware modules.
107      */
getExclusiveGroupId()108     public int getExclusiveGroupId() {
109         return mExclusiveGroupId;
110     }
111     /**
112      * Gets status capabilities.
113      *
114      * @return An array of supported status types.
115      */
116     @FrontendStatusType
117     @NonNull
getStatusCapabilities()118     public int[] getStatusCapabilities() {
119         return mStatusCaps;
120     }
121     /**
122      * Gets frontend capabilities.
123      */
124     @NonNull
getFrontendCapabilities()125     public FrontendCapabilities getFrontendCapabilities() {
126         return mFrontendCap;
127     }
128 
129 
130     /** @hide */
131     @Override
equals(Object o)132     public boolean equals(Object o) {
133         if (this == o) {
134             return true;
135         }
136         if (o == null || !(o instanceof FrontendInfo)) {
137             return false;
138         }
139         // TODO: compare FrontendCapabilities
140         FrontendInfo info = (FrontendInfo) o;
141         return mId == info.getId() && mType == info.getType()
142                 && Objects.equals(mFrequencyRange, info.getFrequencyRange())
143                 && Objects.equals(mSymbolRateRange, info.getSymbolRateRange())
144                 && mAcquireRange == info.getAcquireRange()
145                 && mExclusiveGroupId == info.getExclusiveGroupId()
146                 && Arrays.equals(mStatusCaps, info.getStatusCapabilities());
147     }
148 
149     /** @hide */
150     @Override
hashCode()151     public int hashCode() {
152         return mId;
153     }
154 }
155