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 
86     @Override
equals(Object o)87     public boolean equals (Object o) {
88         RestrictedState s;
89 
90         try {
91             s = (RestrictedState) o;
92         } catch (ClassCastException ex) {
93             return false;
94         }
95 
96         if (o == null) {
97             return false;
98         }
99 
100         return mPsRestricted == s.mPsRestricted
101         && mCsNormalRestricted == s.mCsNormalRestricted
102         && mCsEmergencyRestricted == s.mCsEmergencyRestricted;
103     }
104 
105     @Override
toString()106     public String toString() {
107         String csString = "none";
108 
109         if (mCsEmergencyRestricted && mCsNormalRestricted) {
110             csString = "all";
111         } else if (mCsEmergencyRestricted && !mCsNormalRestricted) {
112             csString = "emergency";
113         } else if (!mCsEmergencyRestricted && mCsNormalRestricted) {
114             csString = "normal call";
115         }
116 
117         return  "Restricted State CS: " + csString + " PS:" + mPsRestricted;
118     }
119 
120 }
121