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