1 /*
2  * Copyright (C) 2009 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 com.android.internal.telephony.gsm;
18 
19 import java.util.Objects;
20 
21 /**
22  * SmsBroadcastConfigInfo defines one configuration of Cell Broadcast
23  * Message (CBM) to be received by the ME
24  *
25  * fromServiceId - toServiceId defines a range of CBM message identifiers
26  * whose value is 0x0000 - 0xFFFF as defined in TS 23.041 9.4.1.2.2 for GMS
27  * and 9.4.4.2.2 for UMTS. All other values can be treated as empty
28  * CBM message ID.
29  *
30  * fromCodeScheme - toCodeScheme defines a range of CBM data coding schemes
31  * whose value is 0x00 - 0xFF as defined in TS 23.041 9.4.1.2.3 for GMS
32  * and 9.4.4.2.3 for UMTS.
33  * All other values can be treated as empty CBM data coding scheme.
34  *
35  * selected false means message types specified in {@code <fromServiceId, toServiceId>}
36  * and {@code <fromCodeScheme, toCodeScheme>} are not accepted, while true means accepted.
37  *
38  */
39 public final class SmsBroadcastConfigInfo {
40     private int mFromServiceId;
41     private int mToServiceId;
42     private int mFromCodeScheme;
43     private int mToCodeScheme;
44     private boolean mSelected;
45 
46     /**
47      * Initialize the object from rssi and cid.
48      */
SmsBroadcastConfigInfo(int fromId, int toId, int fromScheme, int toScheme, boolean selected)49     public SmsBroadcastConfigInfo(int fromId, int toId, int fromScheme,
50             int toScheme, boolean selected) {
51         mFromServiceId = fromId;
52         mToServiceId = toId;
53         mFromCodeScheme = fromScheme;
54         mToCodeScheme = toScheme;
55         mSelected = selected;
56     }
57 
58     /**
59      * @param fromServiceId the fromServiceId to set
60      */
setFromServiceId(int fromServiceId)61     public void setFromServiceId(int fromServiceId) {
62         mFromServiceId = fromServiceId;
63     }
64 
65     /**
66      * @return the fromServiceId
67      */
getFromServiceId()68     public int getFromServiceId() {
69         return mFromServiceId;
70     }
71 
72     /**
73      * @param toServiceId the toServiceId to set
74      */
setToServiceId(int toServiceId)75     public void setToServiceId(int toServiceId) {
76         mToServiceId = toServiceId;
77     }
78 
79     /**
80      * @return the toServiceId
81      */
getToServiceId()82     public int getToServiceId() {
83         return mToServiceId;
84     }
85 
86     /**
87      * @param fromCodeScheme the fromCodeScheme to set
88      */
setFromCodeScheme(int fromCodeScheme)89     public void setFromCodeScheme(int fromCodeScheme) {
90         mFromCodeScheme = fromCodeScheme;
91     }
92 
93     /**
94      * @return the fromCodeScheme
95      */
getFromCodeScheme()96     public int getFromCodeScheme() {
97         return mFromCodeScheme;
98     }
99 
100     /**
101      * @param toCodeScheme the toCodeScheme to set
102      */
setToCodeScheme(int toCodeScheme)103     public void setToCodeScheme(int toCodeScheme) {
104         mToCodeScheme = toCodeScheme;
105     }
106 
107     /**
108      * @return the toCodeScheme
109      */
getToCodeScheme()110     public int getToCodeScheme() {
111         return mToCodeScheme;
112     }
113 
114     /**
115      * @param selected the selected to set
116      */
setSelected(boolean selected)117     public void setSelected(boolean selected) {
118         mSelected = selected;
119     }
120 
121     /**
122      * @return the selected
123      */
isSelected()124     public boolean isSelected() {
125         return mSelected;
126     }
127 
128     @Override
toString()129     public String toString() {
130         return "SmsBroadcastConfigInfo: Id [" +
131                 mFromServiceId + ',' + mToServiceId + "] Code [" +
132                 mFromCodeScheme + ',' + mToCodeScheme + "] " +
133             (mSelected ? "ENABLED" : "DISABLED");
134     }
135 
136     @Override
hashCode()137     public int hashCode() {
138         return Objects.hash(mFromServiceId, mToServiceId,
139                 mFromCodeScheme, mToCodeScheme, mSelected);
140     }
141 
142     @Override
equals(Object obj)143     public boolean equals(Object obj) {
144         if (!(obj instanceof SmsBroadcastConfigInfo)) {
145             return false;
146         }
147 
148         SmsBroadcastConfigInfo other = (SmsBroadcastConfigInfo) obj;
149 
150         return mFromServiceId == other.mFromServiceId
151                 && mToServiceId == other.mToServiceId
152                 && mFromCodeScheme == other.mFromCodeScheme
153                 && mToCodeScheme == other.mToCodeScheme && mSelected == other.mSelected;
154     }
155 }
156