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.filter;
18 
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 import android.hardware.tv.tuner.Constant;
22 
23 /**
24  * Table information for Section Filter.
25  *
26  * @hide
27  */
28 @SystemApi
29 public class SectionSettingsWithTableInfo extends SectionSettings {
30     /**
31      * The invalid version number of {@link SectionSettingsWithTableInfo}. Tuner HAL will ignore the
32      * {@link SectionSettingsWithTableInfo} version number if this invalid version is set.
33      */
34     public static final int INVALID_TABLE_INFO_VERSION = Constant.INVALID_TABINFO_VERSION;
35 
36     private final int mTableId;
37     private final int mVersion;
38 
SectionSettingsWithTableInfo(int mainType, boolean isCheckCrc, boolean isRepeat, boolean isRaw, int bitWidthOfLengthField, int tableId, int version)39     private SectionSettingsWithTableInfo(int mainType, boolean isCheckCrc, boolean isRepeat,
40             boolean isRaw, int bitWidthOfLengthField, int tableId, int version) {
41         super(mainType, isCheckCrc, isRepeat, isRaw, bitWidthOfLengthField);
42         mTableId = tableId;
43         mVersion = version;
44     }
45 
46     /**
47      * Gets table ID.
48      */
getTableId()49     public int getTableId() {
50         return mTableId;
51     }
52     /**
53      * Gets version.
54      */
getVersion()55     public int getVersion() {
56         return mVersion;
57     }
58 
59     /**
60      * Creates a builder for {@link SectionSettingsWithTableInfo}.
61      *
62      * @param mainType the filter main type.
63      */
64     @NonNull
builder(@ilter.Type int mainType)65     public static Builder builder(@Filter.Type int mainType) {
66         return new Builder(mainType);
67     }
68 
69     /**
70      * Builder for {@link SectionSettingsWithTableInfo}.
71      */
72     public static class Builder extends SectionSettings.Builder<Builder> {
73         private int mTableId;
74         private int mVersion = INVALID_TABLE_INFO_VERSION;
75 
Builder(int mainType)76         private Builder(int mainType) {
77             super(mainType);
78         }
79 
80         /**
81          * Sets table ID.
82          */
83         @NonNull
setTableId(int tableId)84         public Builder setTableId(int tableId) {
85             mTableId = tableId;
86             return this;
87         }
88         /**
89          * Sets version.
90          */
91         @NonNull
setVersion(int version)92         public Builder setVersion(int version) {
93             mVersion = version;
94             return this;
95         }
96 
97         /**
98          * Builds a {@link SectionSettingsWithTableInfo} object.
99          */
100         @NonNull
build()101         public SectionSettingsWithTableInfo build() {
102             return new SectionSettingsWithTableInfo(mMainType, mCrcEnabled, mIsRepeat, mIsRaw,
103                     mBitWidthOfLengthField, mTableId, mVersion);
104         }
105 
106         @Override
self()107         Builder self() {
108             return this;
109         }
110     }
111 
112 }
113