2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.telephony;
19 import android.graphics.drawable.BitmapDrawable;
20 import android.os.Parcel;
21 import android.os.Parcelable;
24 * A Parcelable class for Subscription Information.
27 public class SubInfoRecord implements Parcelable {
30 * Subscription Identifier, this is a device unique number
31 * and not an index into an array
34 /** The GID for a SIM that maybe associated with this subscription, empty if unknown */
37 * The slot identifier for that currently contains the subscription
38 * and not necessarily unique and maybe INVALID_SLOT_ID if unknown
42 * The string displayed to the user that identifies this subscription
44 public String displayName;
46 * The source of the name, NAME_SOURCE_UNDEFINED, NAME_SOURCE_DEFAULT_SOURCE,
47 * NAME_SOURCE_SIM_SOURCE or NAME_SOURCE_USER_INPUT.
49 public int nameSource;
51 * The color to be used for when displaying to the user
55 * A number presented to the user identify this subscription
59 * How to display the phone number, DISPLAY_NUMBER_NONE, DISPLAY_NUMBER_FIRST,
62 public int displayNumberFormat;
64 * Data roaming state, DATA_RAOMING_ENABLE, DATA_RAOMING_DISABLE
66 public int dataRoaming;
68 * SIM Icon resource identifiers. FIXME: Check with MTK what it really is
70 public int[] simIconRes;
80 public SubInfoRecord() {
81 this.subId = SubscriptionManager.INVALID_SUB_ID;
83 this.slotId = SubscriptionManager.INVALID_SLOT_ID;
84 this.displayName = "";
88 this.displayNumberFormat = 0;
90 this.simIconRes = new int[2];
95 public SubInfoRecord(long subId, String iccId, int slotId, String displayName, int nameSource,
96 int color, String number, int displayFormat, int roaming, int[] iconRes,
100 this.slotId = slotId;
101 this.displayName = displayName;
102 this.nameSource = nameSource;
104 this.number = number;
105 this.displayNumberFormat = displayFormat;
106 this.dataRoaming = roaming;
107 this.simIconRes = iconRes;
113 * Returns the string displayed to the user that identifies this subscription
115 public String getLabel() {
116 return this.displayName;
120 * Return the icon used to identify this SIM.
121 * TODO: return the correct drawable.
123 public BitmapDrawable getIconDrawable() {
124 return new BitmapDrawable();
128 * Return the color to be used for when displaying to the user. This is the value of the color.
131 public int getColor() {
132 // Note: This color is currently an index into a list of drawables, but this is soon to
137 public static final Parcelable.Creator<SubInfoRecord> CREATOR = new Parcelable.Creator<SubInfoRecord>() {
139 public SubInfoRecord createFromParcel(Parcel source) {
140 long subId = source.readLong();
141 String iccId = source.readString();
142 int slotId = source.readInt();
143 String displayName = source.readString();
144 int nameSource = source.readInt();
145 int color = source.readInt();
146 String number = source.readString();
147 int displayNumberFormat = source.readInt();
148 int dataRoaming = source.readInt();
149 int[] iconRes = new int[2];
150 source.readIntArray(iconRes);
151 int mcc = source.readInt();
152 int mnc = source.readInt();
154 return new SubInfoRecord(subId, iccId, slotId, displayName, nameSource, color, number,
155 displayNumberFormat, dataRoaming, iconRes, mcc, mnc);
159 public SubInfoRecord[] newArray(int size) {
160 return new SubInfoRecord[size];
165 public void writeToParcel(Parcel dest, int flags) {
166 dest.writeLong(subId);
167 dest.writeString(iccId);
168 dest.writeInt(slotId);
169 dest.writeString(displayName);
170 dest.writeInt(nameSource);
171 dest.writeInt(color);
172 dest.writeString(number);
173 dest.writeInt(displayNumberFormat);
174 dest.writeInt(dataRoaming);
175 dest.writeIntArray(simIconRes);
181 public int describeContents() {
186 public String toString() {
187 return "{mSubId=" + subId + ", mIccId=" + iccId + " mSlotId=" + slotId
188 + " mDisplayName=" + displayName + " mNameSource=" + nameSource
189 + " mColor=" + color + " mNumber=" + number
190 + " mDisplayNumberFormat=" + displayNumberFormat + " mDataRoaming=" + dataRoaming
191 + " mSimIconRes=" + simIconRes + " mMcc " + mcc + " mMnc " + mnc + "}";