1 /* 2 * Copyright (C) 2006 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; 18 19 public class RestrictedState { 20 21 /** 22 * Set true to block packet data access due to restriction 23 */ 24 private boolean mPsRestricted; 25 /** 26 * Set true to block all normal voice/SMS/USSD/SS/AV64 due to restriction 27 */ 28 private boolean mCsNormalRestricted; 29 /** 30 * Set true to block emergency call due to restriction 31 */ 32 private boolean mCsEmergencyRestricted; 33 RestrictedState()34 public RestrictedState() { 35 setPsRestricted(false); 36 setCsNormalRestricted(false); 37 setCsEmergencyRestricted(false); 38 } 39 40 /** 41 * @param csEmergencyRestricted the csEmergencyRestricted to set 42 */ setCsEmergencyRestricted(boolean csEmergencyRestricted)43 public void setCsEmergencyRestricted(boolean csEmergencyRestricted) { 44 mCsEmergencyRestricted = csEmergencyRestricted; 45 } 46 47 /** 48 * @return the csEmergencyRestricted 49 */ isCsEmergencyRestricted()50 public boolean isCsEmergencyRestricted() { 51 return mCsEmergencyRestricted; 52 } 53 54 /** 55 * @param csNormalRestricted the csNormalRestricted to set 56 */ setCsNormalRestricted(boolean csNormalRestricted)57 public void setCsNormalRestricted(boolean csNormalRestricted) { 58 mCsNormalRestricted = csNormalRestricted; 59 } 60 61 /** 62 * @return the csNormalRestricted 63 */ isCsNormalRestricted()64 public boolean isCsNormalRestricted() { 65 return mCsNormalRestricted; 66 } 67 68 /** 69 * @param psRestricted the psRestricted to set 70 */ setPsRestricted(boolean psRestricted)71 public void setPsRestricted(boolean psRestricted) { 72 mPsRestricted = psRestricted; 73 } 74 75 /** 76 * @return the psRestricted 77 */ isPsRestricted()78 public boolean isPsRestricted() { 79 return mPsRestricted; 80 } 81 isCsRestricted()82 public boolean isCsRestricted() { 83 return mCsNormalRestricted && mCsEmergencyRestricted; 84 } 85 isAnyCsRestricted()86 public boolean isAnyCsRestricted() { 87 return mCsNormalRestricted || mCsEmergencyRestricted; 88 } 89 90 @Override equals(Object o)91 public boolean equals (Object o) { 92 RestrictedState s; 93 94 try { 95 s = (RestrictedState) o; 96 } catch (ClassCastException ex) { 97 return false; 98 } 99 100 if (o == null) { 101 return false; 102 } 103 104 return mPsRestricted == s.mPsRestricted 105 && mCsNormalRestricted == s.mCsNormalRestricted 106 && mCsEmergencyRestricted == s.mCsEmergencyRestricted; 107 } 108 109 @Override toString()110 public String toString() { 111 String csString = "none"; 112 113 if (mCsEmergencyRestricted && mCsNormalRestricted) { 114 csString = "all"; 115 } else if (mCsEmergencyRestricted && !mCsNormalRestricted) { 116 csString = "emergency"; 117 } else if (!mCsEmergencyRestricted && mCsNormalRestricted) { 118 csString = "normal call"; 119 } 120 121 return "Restricted State CS: " + csString + " PS:" + mPsRestricted; 122 } 123 124 } 125