OSDN Git Service

am e726495a: am fe5e7e92: Merge "docs: Fix issue with onCreate() method declaration...
[android-x86/frameworks-base.git] / telephony / java / android / telephony / SubInfoRecord.java
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.graphics.drawable.BitmapDrawable;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22
23 /**
24  * A Parcelable class for Subscription Information.
25  * @hide
26  */
27 public class SubInfoRecord implements Parcelable {
28
29     /**
30      * Subscription Identifier, this is a device unique number
31      * and not an index into an array
32      */
33     public long subId;
34     /** The GID for a SIM that maybe associated with this subscription, empty if unknown */
35     public String iccId;
36     /**
37      * The slot identifier for that currently contains the subscription
38      * and not necessarily unique and maybe INVALID_SLOT_ID if unknown
39      */
40     public int slotId;
41     /**
42      * The string displayed to the user that identifies this subscription
43      */
44     public String displayName;
45     /**
46      * The source of the name, NAME_SOURCE_UNDEFINED, NAME_SOURCE_DEFAULT_SOURCE,
47      * NAME_SOURCE_SIM_SOURCE or NAME_SOURCE_USER_INPUT.
48      */
49     public int nameSource;
50     /**
51      * The color to be used for when displaying to the user
52      */
53     public int color;
54     /**
55      * A number presented to the user identify this subscription
56      */
57     public String number;
58     /**
59      * How to display the phone number, DISPLAY_NUMBER_NONE, DISPLAY_NUMBER_FIRST,
60      * DISPLAY_NUMBER_LAST
61      */
62     public int displayNumberFormat;
63     /**
64      * Data roaming state, DATA_RAOMING_ENABLE, DATA_RAOMING_DISABLE
65      */
66     public int dataRoaming;
67     /**
68      * SIM Icon resource identifiers. FIXME: Check with MTK what it really is
69      */
70     public int[] simIconRes;
71     /**
72      * Mobile Country Code
73      */
74     public int mcc;
75     /**
76      * Mobile Network Code
77      */
78     public int mnc;
79
80     public SubInfoRecord() {
81         this.subId = SubscriptionManager.INVALID_SUB_ID;
82         this.iccId = "";
83         this.slotId = SubscriptionManager.INVALID_SLOT_ID;
84         this.displayName = "";
85         this.nameSource = 0;
86         this.color = 0;
87         this.number = "";
88         this.displayNumberFormat = 0;
89         this.dataRoaming = 0;
90         this.simIconRes = new int[2];
91         this.mcc = 0;
92         this.mnc = 0;
93     }
94
95     public SubInfoRecord(long subId, String iccId, int slotId, String displayName, int nameSource,
96             int color, String number, int displayFormat, int roaming, int[] iconRes,
97             int mcc, int mnc) {
98         this.subId = subId;
99         this.iccId = iccId;
100         this.slotId = slotId;
101         this.displayName = displayName;
102         this.nameSource = nameSource;
103         this.color = color;
104         this.number = number;
105         this.displayNumberFormat = displayFormat;
106         this.dataRoaming = roaming;
107         this.simIconRes = iconRes;
108         this.mcc = mcc;
109         this.mnc = mnc;
110     }
111
112     /**
113      * Returns the string displayed to the user that identifies this subscription
114      */
115     public String getLabel() {
116         return this.displayName;
117     }
118
119     /**
120      * Return the icon used to identify this SIM.
121      * TODO: return the correct drawable.
122      */
123     public BitmapDrawable getIconDrawable() {
124         return new BitmapDrawable();
125     }
126
127     /**
128      * Return the color to be used for when displaying to the user. This is the value of the color.
129      * ex: 0x00ff00
130      */
131     public int getColor() {
132         // Note: This color is currently an index into a list of drawables, but this is soon to
133         // change.
134         return this.color;
135     }
136
137     public static final Parcelable.Creator<SubInfoRecord> CREATOR = new Parcelable.Creator<SubInfoRecord>() {
138         @Override
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();
153
154             return new SubInfoRecord(subId, iccId, slotId, displayName, nameSource, color, number,
155                 displayNumberFormat, dataRoaming, iconRes, mcc, mnc);
156         }
157
158         @Override
159         public SubInfoRecord[] newArray(int size) {
160             return new SubInfoRecord[size];
161         }
162     };
163
164     @Override
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);
176         dest.writeInt(mcc);
177         dest.writeInt(mnc);
178     }
179
180     @Override
181     public int describeContents() {
182         return 0;
183     }
184
185     @Override
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 + "}";
192     }
193 }