1 /* 2 * Copyright (C) 2009 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.cdma; 18 19 import android.os.Parcel; 20 21 public final class CdmaInformationRecords { 22 public Object record; 23 24 /** 25 * Record type identifier 26 */ 27 public static final int RIL_CDMA_DISPLAY_INFO_REC = 0; 28 public static final int RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC = 1; 29 public static final int RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC = 2; 30 public static final int RIL_CDMA_CONNECTED_NUMBER_INFO_REC = 3; 31 public static final int RIL_CDMA_SIGNAL_INFO_REC = 4; 32 public static final int RIL_CDMA_REDIRECTING_NUMBER_INFO_REC = 5; 33 public static final int RIL_CDMA_LINE_CONTROL_INFO_REC = 6; 34 public static final int RIL_CDMA_EXTENDED_DISPLAY_INFO_REC = 7; 35 public static final int RIL_CDMA_T53_CLIR_INFO_REC = 8; 36 public static final int RIL_CDMA_T53_RELEASE_INFO_REC = 9; 37 public static final int RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC = 10; 38 CdmaInformationRecords(CdmaDisplayInfoRec obj)39 public CdmaInformationRecords(CdmaDisplayInfoRec obj) { 40 record = obj; 41 } 42 CdmaInformationRecords(CdmaNumberInfoRec obj)43 public CdmaInformationRecords(CdmaNumberInfoRec obj) { 44 record = obj; 45 } 46 CdmaInformationRecords(CdmaSignalInfoRec obj)47 public CdmaInformationRecords(CdmaSignalInfoRec obj) { 48 record = obj; 49 } 50 CdmaInformationRecords(CdmaRedirectingNumberInfoRec obj)51 public CdmaInformationRecords(CdmaRedirectingNumberInfoRec obj) { 52 record = obj; 53 } 54 CdmaInformationRecords(CdmaLineControlInfoRec obj)55 public CdmaInformationRecords(CdmaLineControlInfoRec obj) { 56 record = obj; 57 } 58 CdmaInformationRecords(CdmaT53ClirInfoRec obj)59 public CdmaInformationRecords(CdmaT53ClirInfoRec obj) { 60 record = obj; 61 } 62 CdmaInformationRecords(CdmaT53AudioControlInfoRec obj)63 public CdmaInformationRecords(CdmaT53AudioControlInfoRec obj) { 64 record = obj; 65 } 66 CdmaInformationRecords(Parcel p)67 public CdmaInformationRecords(Parcel p) { 68 int id = p.readInt(); 69 switch (id) { 70 case RIL_CDMA_DISPLAY_INFO_REC: 71 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: 72 record = new CdmaDisplayInfoRec(id, p.readString()); 73 break; 74 75 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC: 76 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC: 77 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: 78 record = new CdmaNumberInfoRec(id, p.readString(), p.readInt(), p.readInt(), 79 p.readInt(), p.readInt()); 80 break; 81 82 case RIL_CDMA_SIGNAL_INFO_REC: 83 record = new CdmaSignalInfoRec(p.readInt(), p.readInt(), p.readInt(), p.readInt()); 84 break; 85 86 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: 87 record = new CdmaRedirectingNumberInfoRec(p.readString(), p.readInt(), p.readInt(), 88 p.readInt(), p.readInt(), p.readInt()); 89 break; 90 91 case RIL_CDMA_LINE_CONTROL_INFO_REC: 92 record = new CdmaLineControlInfoRec(p.readInt(), p.readInt(), p.readInt(), 93 p.readInt()); 94 break; 95 96 case RIL_CDMA_T53_CLIR_INFO_REC: 97 record = new CdmaT53ClirInfoRec(p.readInt()); 98 break; 99 100 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: 101 record = new CdmaT53AudioControlInfoRec(p.readInt(), p.readInt()); 102 break; 103 104 case RIL_CDMA_T53_RELEASE_INFO_REC: 105 // TODO: WHAT to do, for now fall through and throw exception 106 default: 107 throw new RuntimeException("RIL_UNSOL_CDMA_INFO_REC: unsupported record. Got " 108 + CdmaInformationRecords.idToString(id) + " "); 109 110 } 111 } 112 idToString(int id)113 public static String idToString(int id) { 114 switch(id) { 115 case RIL_CDMA_DISPLAY_INFO_REC: return "RIL_CDMA_DISPLAY_INFO_REC"; 116 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC: return "RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC"; 117 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC: return "RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC"; 118 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: return "RIL_CDMA_CONNECTED_NUMBER_INFO_REC"; 119 case RIL_CDMA_SIGNAL_INFO_REC: return "RIL_CDMA_SIGNAL_INFO_REC"; 120 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: return "RIL_CDMA_REDIRECTING_NUMBER_INFO_REC"; 121 case RIL_CDMA_LINE_CONTROL_INFO_REC: return "RIL_CDMA_LINE_CONTROL_INFO_REC"; 122 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: return "RIL_CDMA_EXTENDED_DISPLAY_INFO_REC"; 123 case RIL_CDMA_T53_CLIR_INFO_REC: return "RIL_CDMA_T53_CLIR_INFO_REC"; 124 case RIL_CDMA_T53_RELEASE_INFO_REC: return "RIL_CDMA_T53_RELEASE_INFO_REC"; 125 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: return "RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC"; 126 default: return "<unknown record>"; 127 } 128 } 129 130 /** 131 * Signal Information record from 3GPP2 C.S005 3.7.5.5 132 */ 133 public static class CdmaSignalInfoRec { 134 public boolean isPresent; /* non-zero if signal information record is present */ 135 public int signalType; 136 public int alertPitch; 137 public int signal; 138 CdmaSignalInfoRec()139 public CdmaSignalInfoRec() {} 140 CdmaSignalInfoRec(int isPresent, int signalType, int alertPitch, int signal)141 public CdmaSignalInfoRec(int isPresent, int signalType, int alertPitch, int signal) { 142 this.isPresent = isPresent != 0; 143 this.signalType = signalType; 144 this.alertPitch = alertPitch; 145 this.signal = signal; 146 } 147 148 @Override toString()149 public String toString() { 150 return "CdmaSignalInfo: {" + 151 " isPresent: " + isPresent + 152 ", signalType: " + signalType + 153 ", alertPitch: " + alertPitch + 154 ", signal: " + signal + 155 " }"; 156 } 157 } 158 159 public static class CdmaDisplayInfoRec { 160 public int id; 161 public String alpha; 162 CdmaDisplayInfoRec(int id, String alpha)163 public CdmaDisplayInfoRec(int id, String alpha) { 164 this.id = id; 165 this.alpha = alpha; 166 } 167 168 @Override toString()169 public String toString() { 170 return "CdmaDisplayInfoRec: {" + 171 " id: " + CdmaInformationRecords.idToString(id) + 172 ", alpha: " + alpha + 173 " }"; 174 } 175 } 176 177 public static class CdmaNumberInfoRec { 178 public int id; 179 public String number; 180 public byte numberType; 181 public byte numberPlan; 182 public byte pi; 183 public byte si; 184 CdmaNumberInfoRec(int id, String number, int numberType, int numberPlan, int pi, int si)185 public CdmaNumberInfoRec(int id, String number, int numberType, int numberPlan, int pi, 186 int si) { 187 this.id = id; 188 this.number = number; 189 this.numberType = (byte)numberType; 190 this.numberPlan = (byte)numberPlan; 191 this.pi = (byte)pi; 192 this.si = (byte)si; 193 } 194 195 @Override toString()196 public String toString() { 197 return "CdmaNumberInfoRec: {" + 198 " id: " + CdmaInformationRecords.idToString(id) + 199 ", number: <MASKED>" + 200 ", numberType: " + numberType + 201 ", numberPlan: " + numberPlan + 202 ", pi: " + pi + 203 ", si: " + si + 204 " }"; 205 } 206 } 207 208 public static class CdmaRedirectingNumberInfoRec { 209 public static final int REASON_UNKNOWN = 0; 210 public static final int REASON_CALL_FORWARDING_BUSY = 1; 211 public static final int REASON_CALL_FORWARDING_NO_REPLY = 2; 212 public static final int REASON_CALLED_DTE_OUT_OF_ORDER = 9; 213 public static final int REASON_CALL_FORWARDING_BY_THE_CALLED_DTE = 10; 214 public static final int REASON_CALL_FORWARDING_UNCONDITIONAL = 15; 215 216 public CdmaNumberInfoRec numberInfoRec; 217 public int redirectingReason; 218 CdmaRedirectingNumberInfoRec(String number, int numberType, int numberPlan, int pi, int si, int reason)219 public CdmaRedirectingNumberInfoRec(String number, int numberType, int numberPlan, 220 int pi, int si, int reason) { 221 numberInfoRec = new CdmaNumberInfoRec(RIL_CDMA_REDIRECTING_NUMBER_INFO_REC, 222 number, numberType, numberPlan, pi, si); 223 redirectingReason = reason; 224 } 225 226 @Override toString()227 public String toString() { 228 return "CdmaNumberInfoRec: {" + 229 " numberInfoRec: " + numberInfoRec + 230 ", redirectingReason: " + redirectingReason + 231 " }"; 232 } 233 } 234 235 public static class CdmaLineControlInfoRec { 236 public byte lineCtrlPolarityIncluded; 237 public byte lineCtrlToggle; 238 public byte lineCtrlReverse; 239 public byte lineCtrlPowerDenial; 240 CdmaLineControlInfoRec(int lineCtrlPolarityIncluded, int lineCtrlToggle, int lineCtrlReverse, int lineCtrlPowerDenial)241 public CdmaLineControlInfoRec(int lineCtrlPolarityIncluded, int lineCtrlToggle, 242 int lineCtrlReverse, int lineCtrlPowerDenial) { 243 this.lineCtrlPolarityIncluded = (byte)lineCtrlPolarityIncluded; 244 this.lineCtrlToggle = (byte)lineCtrlToggle; 245 this.lineCtrlReverse = (byte)lineCtrlReverse; 246 this.lineCtrlPowerDenial = (byte)lineCtrlPowerDenial; 247 } 248 249 @Override toString()250 public String toString() { 251 return "CdmaLineControlInfoRec: {" + 252 " lineCtrlPolarityIncluded: " + lineCtrlPolarityIncluded + 253 " lineCtrlToggle: " + lineCtrlToggle + 254 " lineCtrlReverse: " + lineCtrlReverse + 255 " lineCtrlPowerDenial: " + lineCtrlPowerDenial + 256 " }"; 257 } 258 } 259 260 public static class CdmaT53ClirInfoRec { 261 public byte cause; 262 CdmaT53ClirInfoRec(int cause)263 public CdmaT53ClirInfoRec(int cause) { 264 this.cause = (byte)cause; 265 } 266 267 @Override toString()268 public String toString() { 269 return "CdmaT53ClirInfoRec: {" + 270 " cause: " + cause + 271 " }"; 272 } 273 } 274 275 public static class CdmaT53AudioControlInfoRec { 276 public byte uplink; 277 public byte downlink; 278 CdmaT53AudioControlInfoRec(int uplink, int downlink)279 public CdmaT53AudioControlInfoRec(int uplink, int downlink) { 280 this.uplink = (byte) uplink; 281 this.downlink = (byte) downlink; 282 } 283 284 @Override toString()285 public String toString() { 286 return "CdmaT53AudioControlInfoRec: {" + 287 " uplink: " + uplink + 288 " downlink: " + downlink + 289 " }"; 290 } 291 } 292 } 293