blob: d10a7ea5ec4124b404bb9224f40083dcec2e73ce [file] [log] [blame]
Wink Saville2af2d572014-10-17 15:03:58 -07001/*
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
17package android.telephony;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
Stuart Scott997ddc82014-12-04 15:01:31 -080022import com.android.internal.telephony.RILConstants;
23
Wink Saville2af2d572014-10-17 15:03:58 -070024/**
25 * Object to indicate the phone radio type and access technology.
26 *
27 * @hide
28 */
29public class RadioAccessFamily implements Parcelable {
30
31 // Radio Access Family
32 public static final int RAF_UNKNOWN = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN);
33 public static final int RAF_GPRS = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_GPRS);
34 public static final int RAF_EDGE = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_EDGE);
35 public static final int RAF_UMTS = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_UMTS);
36 public static final int RAF_IS95A = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_IS95A);
37 public static final int RAF_IS95B = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_IS95B);
38 public static final int RAF_1xRTT = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT);
39 public static final int RAF_EVDO_0 = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0);
40 public static final int RAF_EVDO_A = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A);
41 public static final int RAF_HSDPA = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA);
42 public static final int RAF_HSUPA = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA);
43 public static final int RAF_HSPA = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_HSPA);
44 public static final int RAF_EVDO_B = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B);
45 public static final int RAF_EHRPD = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD);
46 public static final int RAF_LTE = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_LTE);
47 public static final int RAF_HSPAP = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP);
48 public static final int RAF_GSM = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_GSM);
49 public static final int RAF_TD_SCDMA = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA);
50
51 /* Phone ID of phone */
52 private int mPhoneId;
53
54 /* Radio Access Family */
55 private int mRadioAccessFamily;
56
57 /**
58 * Constructor.
59 *
60 * @param phoneId the phone ID
61 * @param radioAccessFamily the phone radio access family defined
62 * in RadioAccessFamily. It's a bit mask value to represent
63 * the support type.
64 */
65 public RadioAccessFamily(int phoneId, int radioAccessFamily) {
66 mPhoneId = phoneId;
67 mRadioAccessFamily = radioAccessFamily;
68 }
69
70 /**
71 * Get phone ID.
72 *
73 * @return phone ID
74 */
75 public int getPhoneId() {
76 return mPhoneId;
77 }
78
79 /**
80 * get radio access family.
81 *
82 * @return radio access family
83 */
84 public int getRadioAccessFamily() {
85 return mRadioAccessFamily;
86 }
87
88 @Override
89 public String toString() {
90 String ret = "{ mPhoneId = " + mPhoneId
91 + ", mRadioAccessFamily = " + mRadioAccessFamily
92 + "}";
93 return ret;
94 }
95
96 /**
97 * Implement the Parcelable interface.
98 *
99 * @return describe content
100 */
101 @Override
102 public int describeContents() {
103 return 0;
104 }
105
106 /**
107 * Implement the Parcelable interface.
108 *
109 * @param outParcel The Parcel in which the object should be written.
110 * @param flags Additional flags about how the object should be written.
111 */
Stuart Scott997ddc82014-12-04 15:01:31 -0800112 @Override
Wink Saville2af2d572014-10-17 15:03:58 -0700113 public void writeToParcel(Parcel outParcel, int flags) {
114 outParcel.writeInt(mPhoneId);
115 outParcel.writeInt(mRadioAccessFamily);
116 }
117
118 /**
119 * Implement the Parcelable interface.
120 */
121 public static final Creator<RadioAccessFamily> CREATOR =
122 new Creator<RadioAccessFamily>() {
123
124 @Override
125 public RadioAccessFamily createFromParcel(Parcel in) {
126 int phoneId = in.readInt();
127 int radioAccessFamily = in.readInt();
128
129 return new RadioAccessFamily(phoneId, radioAccessFamily);
130 }
131
132 @Override
133 public RadioAccessFamily[] newArray(int size) {
134 return new RadioAccessFamily[size];
135 }
136 };
Stuart Scott997ddc82014-12-04 15:01:31 -0800137
138 public static int getRafFromNetworkType(int type) {
Wink Savillef73c2d12014-12-17 14:38:49 -0800139 final int GSM = RAF_GSM | RAF_GPRS | RAF_EDGE;
140 final int HS = RAF_HSUPA | RAF_HSDPA | RAF_HSPA | RAF_HSPAP;
141 final int CDMA = RAF_IS95A | RAF_IS95B | RAF_1xRTT;
142 final int EVDO = RAF_EVDO_0 | RAF_EVDO_A | RAF_EVDO_B;
143 final int WCDMA = HS | RAF_UMTS;
144
145 int raf;
146
Stuart Scott997ddc82014-12-04 15:01:31 -0800147 switch (type) {
148 case RILConstants.NETWORK_MODE_WCDMA_PREF:
Wink Savillef73c2d12014-12-17 14:38:49 -0800149 raf = GSM | WCDMA;
150 break;
Stuart Scott997ddc82014-12-04 15:01:31 -0800151 case RILConstants.NETWORK_MODE_GSM_ONLY:
Wink Savillef73c2d12014-12-17 14:38:49 -0800152 raf = GSM;
153 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800154 case RILConstants.NETWORK_MODE_WCDMA_ONLY:
Wink Savillef73c2d12014-12-17 14:38:49 -0800155 raf = WCDMA;
156 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800157 case RILConstants.NETWORK_MODE_GSM_UMTS:
Wink Savillef73c2d12014-12-17 14:38:49 -0800158 raf = GSM | WCDMA;
159 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800160 case RILConstants.NETWORK_MODE_CDMA:
Wink Savillef73c2d12014-12-17 14:38:49 -0800161 raf = CDMA;
162 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800163 case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO:
Wink Savillef73c2d12014-12-17 14:38:49 -0800164 raf = RAF_LTE | CDMA | EVDO;
165 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800166 case RILConstants.NETWORK_MODE_LTE_GSM_WCDMA:
Wink Savillef73c2d12014-12-17 14:38:49 -0800167 raf = RAF_LTE | GSM | WCDMA;
168 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800169 case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
Wink Savillef73c2d12014-12-17 14:38:49 -0800170 raf = RAF_LTE | CDMA | EVDO | GSM | WCDMA;
171 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800172 case RILConstants.NETWORK_MODE_LTE_ONLY:
Wink Savillef73c2d12014-12-17 14:38:49 -0800173 raf = RAF_LTE;
174 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800175 case RILConstants.NETWORK_MODE_LTE_WCDMA:
Wink Savillef73c2d12014-12-17 14:38:49 -0800176 raf = RAF_LTE | WCDMA;
177 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800178 case RILConstants.NETWORK_MODE_CDMA_NO_EVDO:
Wink Savillef73c2d12014-12-17 14:38:49 -0800179 raf = CDMA;
180 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800181 case RILConstants.NETWORK_MODE_EVDO_NO_CDMA:
Wink Savillef73c2d12014-12-17 14:38:49 -0800182 raf = EVDO;
183 break;
Stuart Scott482b4242014-12-12 15:55:33 -0800184 case RILConstants.NETWORK_MODE_GLOBAL:
Wink Savillef73c2d12014-12-17 14:38:49 -0800185 raf = GSM | WCDMA | CDMA | EVDO;
186 break;
Stuart Scott997ddc82014-12-04 15:01:31 -0800187 default:
Wink Savillef73c2d12014-12-17 14:38:49 -0800188 raf = RAF_UNKNOWN;
189 break;
Stuart Scott997ddc82014-12-04 15:01:31 -0800190 }
Wink Savilleb5f1e872014-12-19 11:02:01 -0800191 return raf;
Stuart Scott997ddc82014-12-04 15:01:31 -0800192 }
Wink Saville2af2d572014-10-17 15:03:58 -0700193}
194