/telephony/java/com/android/internal/telephony/RestrictedState.java

http://github.com/CyanogenMod/android_frameworks_base · Java · 122 lines · 60 code · 20 blank · 42 comment · 16 complexity · 8fbfd00a01562805660820deba8f24bd MD5 · raw file

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