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