| Wink Saville | 2af2d57 | 2014-10-17 15:03:58 -0700 | [diff] [blame] | 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 | |
| Stuart Scott | 997ddc8 | 2014-12-04 15:01:31 -0800 | [diff] [blame] | 22 | import com.android.internal.telephony.RILConstants; |
| 23 | |
| Wink Saville | 2af2d57 | 2014-10-17 15:03:58 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Object to indicate the phone radio type and access technology. |
| 26 | * |
| 27 | * @hide |
| 28 | */ |
| 29 | public 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 Scott | 997ddc8 | 2014-12-04 15:01:31 -0800 | [diff] [blame] | 112 | @Override |
| Wink Saville | 2af2d57 | 2014-10-17 15:03:58 -0700 | [diff] [blame] | 113 | 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 Scott | 997ddc8 | 2014-12-04 15:01:31 -0800 | [diff] [blame] | 137 | |
| 138 | public static int getRafFromNetworkType(int type) { |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 139 | 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 Scott | 997ddc8 | 2014-12-04 15:01:31 -0800 | [diff] [blame] | 147 | switch (type) { |
| 148 | case RILConstants.NETWORK_MODE_WCDMA_PREF: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 149 | raf = GSM | WCDMA; |
| 150 | break; |
| Stuart Scott | 997ddc8 | 2014-12-04 15:01:31 -0800 | [diff] [blame] | 151 | case RILConstants.NETWORK_MODE_GSM_ONLY: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 152 | raf = GSM; |
| 153 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 154 | case RILConstants.NETWORK_MODE_WCDMA_ONLY: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 155 | raf = WCDMA; |
| 156 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 157 | case RILConstants.NETWORK_MODE_GSM_UMTS: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 158 | raf = GSM | WCDMA; |
| 159 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 160 | case RILConstants.NETWORK_MODE_CDMA: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 161 | raf = CDMA; |
| 162 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 163 | case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 164 | raf = RAF_LTE | CDMA | EVDO; |
| 165 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 166 | case RILConstants.NETWORK_MODE_LTE_GSM_WCDMA: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 167 | raf = RAF_LTE | GSM | WCDMA; |
| 168 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 169 | case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 170 | raf = RAF_LTE | CDMA | EVDO | GSM | WCDMA; |
| 171 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 172 | case RILConstants.NETWORK_MODE_LTE_ONLY: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 173 | raf = RAF_LTE; |
| 174 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 175 | case RILConstants.NETWORK_MODE_LTE_WCDMA: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 176 | raf = RAF_LTE | WCDMA; |
| 177 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 178 | case RILConstants.NETWORK_MODE_CDMA_NO_EVDO: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 179 | raf = CDMA; |
| 180 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 181 | case RILConstants.NETWORK_MODE_EVDO_NO_CDMA: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 182 | raf = EVDO; |
| 183 | break; |
| Stuart Scott | 482b424 | 2014-12-12 15:55:33 -0800 | [diff] [blame] | 184 | case RILConstants.NETWORK_MODE_GLOBAL: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 185 | raf = GSM | WCDMA | CDMA | EVDO; |
| 186 | break; |
| Stuart Scott | 997ddc8 | 2014-12-04 15:01:31 -0800 | [diff] [blame] | 187 | default: |
| Wink Saville | f73c2d1 | 2014-12-17 14:38:49 -0800 | [diff] [blame] | 188 | raf = RAF_UNKNOWN; |
| 189 | break; |
| Stuart Scott | 997ddc8 | 2014-12-04 15:01:31 -0800 | [diff] [blame] | 190 | } |
| Wink Saville | b5f1e87 | 2014-12-19 11:02:01 -0800 | [diff] [blame] | 191 | return raf; |
| Stuart Scott | 997ddc8 | 2014-12-04 15:01:31 -0800 | [diff] [blame] | 192 | } |
| Wink Saville | 2af2d57 | 2014-10-17 15:03:58 -0700 | [diff] [blame] | 193 | } |
| 194 | |