1 /* 2 * Copyright (C) 2011-2013 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 18 package com.android.internal.telephony.cdma; 19 20 import java.util.Objects; 21 22 /** 23 * CdmaSmsBroadcastConfigInfo defines one configuration of Cdma Broadcast 24 * Message to be received by the ME 25 * 26 * serviceCategory defines a Broadcast message identifier 27 * whose value is 0x0000 - 0xFFFF as defined in C.R1001G 9.3.1 and 9.3.2. 28 * All other values can be treated as empty message ID. 29 * 30 * language defines a language code of Broadcast Message 31 * whose value is 0x00 - 0x07 as defined in C.R1001G 9.2. 32 * All other values can be treated as empty language code. 33 * 34 * selected false means message types specified in serviceCategory 35 * are not accepted, while true means accepted. 36 * 37 */ 38 public class CdmaSmsBroadcastConfigInfo { 39 private int mFromServiceCategory; 40 private int mToServiceCategory; 41 private int mLanguage; 42 private boolean mSelected; 43 44 /** 45 * Initialize the object from rssi and cid. 46 */ CdmaSmsBroadcastConfigInfo(int fromServiceCategory, int toServiceCategory, int language, boolean selected)47 public CdmaSmsBroadcastConfigInfo(int fromServiceCategory, int toServiceCategory, 48 int language, boolean selected) { 49 mFromServiceCategory = fromServiceCategory; 50 mToServiceCategory = toServiceCategory; 51 mLanguage = language; 52 mSelected = selected; 53 } 54 55 /** 56 * @return the mFromServiceCategory 57 */ getFromServiceCategory()58 public int getFromServiceCategory() { 59 return mFromServiceCategory; 60 } 61 62 /** 63 * @return the mToServiceCategory 64 */ getToServiceCategory()65 public int getToServiceCategory() { 66 return mToServiceCategory; 67 } 68 69 /** 70 * @return the mLanguage 71 */ getLanguage()72 public int getLanguage() { 73 return mLanguage; 74 } 75 76 /** 77 * @return the selected 78 */ isSelected()79 public boolean isSelected() { 80 return mSelected; 81 } 82 83 @Override toString()84 public String toString() { 85 return "CdmaSmsBroadcastConfigInfo: Id [" + 86 mFromServiceCategory + ", " + mToServiceCategory + "] " + 87 (isSelected() ? "ENABLED" : "DISABLED"); 88 } 89 90 @Override hashCode()91 public int hashCode() { 92 return Objects.hash(mFromServiceCategory, mToServiceCategory, mLanguage, mSelected); 93 } 94 95 @Override equals(Object obj)96 public boolean equals(Object obj) { 97 if (!(obj instanceof CdmaSmsBroadcastConfigInfo)) { 98 return false; 99 } 100 101 CdmaSmsBroadcastConfigInfo other = (CdmaSmsBroadcastConfigInfo) obj; 102 103 return mFromServiceCategory == other.mFromServiceCategory 104 && mToServiceCategory == other.mToServiceCategory 105 && mLanguage == other.mLanguage && mSelected == other.mSelected; 106 } 107 } 108