Home | History | Annotate | Download | only in telephony
      1 /*
      2  * Copyright (C) 2014 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 android.telephony;
     18 
     19 import android.os.Parcel;
     20 import android.os.Parcelable;
     21 
     22 /**
     23  * A Parcelable class for Subscription Information.
     24  * @hide - to be unhidden
     25  */
     26 public class SubInfoRecord implements Parcelable {
     27 
     28     /**
     29      * Subscription Identifier, this is a device unique number
     30      * and not an index into an array
     31      */
     32     public long subId;
     33     /** The GID for a SIM that maybe associated with this subscription, empty if unknown */
     34     public String iccId;
     35     /**
     36      * The slot identifier for that currently contains the subscription
     37      * and not necessarily unique and maybe INVALID_SLOT_ID if unknown
     38      */
     39     public int slotId;
     40     /**
     41      * The string displayed to the user that identifies this subscription
     42      */
     43     public String displayName;
     44     /**
     45      * The source of the name, NAME_SOURCE_UNDEFINED, NAME_SOURCE_DEFAULT_SOURCE,
     46      * NAME_SOURCE_SIM_SOURCE or NAME_SOURCE_USER_INPUT.
     47      */
     48     public int nameSource;
     49     /**
     50      * The color to be used for when displaying to the user
     51      */
     52     public int color;
     53     /**
     54      * A number presented to the user identify this subscription
     55      */
     56     public String number;
     57     /**
     58      * How to display the phone number, DISPLAY_NUMBER_NONE, DISPLAY_NUMBER_FIRST,
     59      * DISPLAY_NUMBER_LAST
     60      */
     61     public int displayNumberFormat;
     62     /**
     63      * Data roaming state, DATA_RAOMING_ENABLE, DATA_RAOMING_DISABLE
     64      */
     65     public int dataRoaming;
     66     /**
     67      * SIM Icon resource identifiers. FIXME: Check with MTK what it really is
     68      */
     69     public int[] simIconRes;
     70     /**
     71      * Mobile Country Code
     72      */
     73     public int mcc;
     74     /**
     75      * Mobile Network Code
     76      */
     77     public int mnc;
     78 
     79     public SubInfoRecord() {
     80         this.subId = SubscriptionManager.INVALID_SUB_ID;
     81         this.iccId = "";
     82         this.slotId = SubscriptionManager.INVALID_SLOT_ID;
     83         this.displayName = "";
     84         this.nameSource = 0;
     85         this.color = 0;
     86         this.number = "";
     87         this.displayNumberFormat = 0;
     88         this.dataRoaming = 0;
     89         this.simIconRes = new int[2];
     90         this.mcc = 0;
     91         this.mnc = 0;
     92     }
     93 
     94     public SubInfoRecord(long subId, String iccId, int slotId, String displayName, int nameSource,
     95             int color, String number, int displayFormat, int roaming, int[] iconRes,
     96             int mcc, int mnc) {
     97         this.subId = subId;
     98         this.iccId = iccId;
     99         this.slotId = slotId;
    100         this.displayName = displayName;
    101         this.nameSource = nameSource;
    102         this.color = color;
    103         this.number = number;
    104         this.displayNumberFormat = displayFormat;
    105         this.dataRoaming = roaming;
    106         this.simIconRes = iconRes;
    107         this.mcc = mcc;
    108         this.mnc = mnc;
    109     }
    110 
    111     public static final Parcelable.Creator<SubInfoRecord> CREATOR = new Parcelable.Creator<SubInfoRecord>() {
    112         @Override
    113         public SubInfoRecord createFromParcel(Parcel source) {
    114             long subId = source.readLong();
    115             String iccId = source.readString();
    116             int slotId = source.readInt();
    117             String displayName = source.readString();
    118             int nameSource = source.readInt();
    119             int color = source.readInt();
    120             String number = source.readString();
    121             int displayNumberFormat = source.readInt();
    122             int dataRoaming = source.readInt();
    123             int[] iconRes = new int[2];
    124             source.readIntArray(iconRes);
    125             int mcc = source.readInt();
    126             int mnc = source.readInt();
    127 
    128             return new SubInfoRecord(subId, iccId, slotId, displayName, nameSource, color, number,
    129                 displayNumberFormat, dataRoaming, iconRes, mcc, mnc);
    130         }
    131 
    132         @Override
    133         public SubInfoRecord[] newArray(int size) {
    134             return new SubInfoRecord[size];
    135         }
    136     };
    137 
    138     @Override
    139     public void writeToParcel(Parcel dest, int flags) {
    140         dest.writeLong(subId);
    141         dest.writeString(iccId);
    142         dest.writeInt(slotId);
    143         dest.writeString(displayName);
    144         dest.writeInt(nameSource);
    145         dest.writeInt(color);
    146         dest.writeString(number);
    147         dest.writeInt(displayNumberFormat);
    148         dest.writeInt(dataRoaming);
    149         dest.writeIntArray(simIconRes);
    150         dest.writeInt(mcc);
    151         dest.writeInt(mnc);
    152     }
    153 
    154     @Override
    155     public int describeContents() {
    156         return 0;
    157     }
    158 
    159     @Override
    160     public String toString() {
    161         return "{mSubId=" + subId + ", mIccId=" + iccId + " mSlotId=" + slotId
    162                 + " mDisplayName=" + displayName + " mNameSource=" + nameSource
    163                 + " mColor=" + color + " mNumber=" + number
    164                 + " mDisplayNumberFormat=" + displayNumberFormat + " mDataRoaming=" + dataRoaming
    165                 + " mSimIconRes=" + simIconRes + " mMcc " + mcc + " mMnc " + mnc + "}";
    166     }
    167 }
    168