Home | History | Annotate | Download | only in cdma
      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 
     39     public CdmaInformationRecords(CdmaDisplayInfoRec obj) {
     40         record = obj;
     41     }
     42 
     43     public CdmaInformationRecords(CdmaNumberInfoRec obj) {
     44         record = obj;
     45     }
     46 
     47     public CdmaInformationRecords(CdmaSignalInfoRec obj) {
     48         record = obj;
     49     }
     50 
     51     public CdmaInformationRecords(CdmaRedirectingNumberInfoRec obj) {
     52         record = obj;
     53     }
     54 
     55     public CdmaInformationRecords(CdmaLineControlInfoRec obj) {
     56         record = obj;
     57     }
     58 
     59     public CdmaInformationRecords(CdmaT53ClirInfoRec obj) {
     60         record = obj;
     61     }
     62 
     63     public CdmaInformationRecords(CdmaT53AudioControlInfoRec obj) {
     64         record = obj;
     65     }
     66 
     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 
    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 
    139         public CdmaSignalInfoRec() {}
    140 
    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
    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 
    163         public CdmaDisplayInfoRec(int id, String alpha) {
    164             this.id = id;
    165             this.alpha = alpha;
    166         }
    167 
    168         @Override
    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 
    185         public CdmaNumberInfoRec(int id, String number, int numberType, int numberPlan, int pi,
    186                 int si) {
    187             this.number = number;
    188             this.numberType = (byte)numberType;
    189             this.numberPlan = (byte)numberPlan;
    190             this.pi = (byte)pi;
    191             this.si = (byte)si;
    192         }
    193 
    194         @Override
    195         public String toString() {
    196             return "CdmaNumberInfoRec: {" +
    197                     " id: " + CdmaInformationRecords.idToString(id) +
    198                     ", number: <MASKED>" +
    199                     ", numberType: " + numberType +
    200                     ", numberPlan: " + numberPlan +
    201                     ", pi: " + pi +
    202                     ", si: " + si +
    203                     " }";
    204         }
    205     }
    206 
    207     public static class CdmaRedirectingNumberInfoRec {
    208         public static final int REASON_UNKNOWN = 0;
    209         public static final int REASON_CALL_FORWARDING_BUSY = 1;
    210         public static final int REASON_CALL_FORWARDING_NO_REPLY = 2;
    211         public static final int REASON_CALLED_DTE_OUT_OF_ORDER = 9;
    212         public static final int REASON_CALL_FORWARDING_BY_THE_CALLED_DTE = 10;
    213         public static final int REASON_CALL_FORWARDING_UNCONDITIONAL = 15;
    214 
    215         public CdmaNumberInfoRec numberInfoRec;
    216         public int redirectingReason;
    217 
    218         public CdmaRedirectingNumberInfoRec(String number, int numberType, int numberPlan,
    219                 int pi, int si, int reason) {
    220             numberInfoRec = new CdmaNumberInfoRec(RIL_CDMA_REDIRECTING_NUMBER_INFO_REC,
    221                                                   number, numberType, numberPlan, pi, si);
    222             redirectingReason = reason;
    223         }
    224 
    225         @Override
    226         public String toString() {
    227             return "CdmaNumberInfoRec: {" +
    228                     " numberInfoRec: " + numberInfoRec +
    229                     ", redirectingReason: " + redirectingReason +
    230                     " }";
    231         }
    232     }
    233 
    234     public static class CdmaLineControlInfoRec {
    235         public byte lineCtrlPolarityIncluded;
    236         public byte lineCtrlToggle;
    237         public byte lineCtrlReverse;
    238         public byte lineCtrlPowerDenial;
    239 
    240         public CdmaLineControlInfoRec(int lineCtrlPolarityIncluded, int lineCtrlToggle,
    241                 int lineCtrlReverse, int lineCtrlPowerDenial) {
    242             this.lineCtrlPolarityIncluded = (byte)lineCtrlPolarityIncluded;
    243             this.lineCtrlToggle = (byte)lineCtrlToggle;
    244             this.lineCtrlReverse = (byte)lineCtrlReverse;
    245             this.lineCtrlPowerDenial = (byte)lineCtrlPowerDenial;
    246         }
    247 
    248         @Override
    249         public String toString() {
    250             return "CdmaLineControlInfoRec: {" +
    251                     " lineCtrlPolarityIncluded: " + lineCtrlPolarityIncluded +
    252                     " lineCtrlToggle: " + lineCtrlToggle +
    253                     " lineCtrlReverse: " + lineCtrlReverse +
    254                     " lineCtrlPowerDenial: " + lineCtrlPowerDenial +
    255                     " }";
    256         }
    257     }
    258 
    259     public static class CdmaT53ClirInfoRec {
    260         public byte cause;
    261 
    262         public CdmaT53ClirInfoRec(int cause) {
    263             this.cause = (byte)cause;
    264         }
    265 
    266         @Override
    267         public String toString() {
    268             return "CdmaT53ClirInfoRec: {" +
    269                     " cause: " + cause +
    270                     " }";
    271         }
    272     }
    273 
    274     public static class CdmaT53AudioControlInfoRec {
    275         public byte uplink;
    276         public byte downlink;
    277 
    278         public CdmaT53AudioControlInfoRec(int uplink, int downlink) {
    279             this.uplink = (byte) uplink;
    280             this.downlink = (byte) downlink;
    281         }
    282 
    283         @Override
    284         public String toString() {
    285             return "CdmaT53AudioControlInfoRec: {" +
    286                     " uplink: " + uplink +
    287                     " downlink: " + downlink +
    288                     " }";
    289         }
    290     }
    291 }
    292