The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 | |
Cassie | d53df96 | 2017-12-05 13:34:33 -0800 | [diff] [blame] | 19 | import android.annotation.IntDef; |
Jack Yu | 8eb6ca8 | 2019-03-01 12:04:50 -0800 | [diff] [blame] | 20 | import android.annotation.NonNull; |
| 21 | import android.annotation.Nullable; |
Jack Yu | f2add90 | 2018-07-12 15:10:34 -0700 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
Jack Yu | 1b8b389 | 2018-02-22 17:37:38 -0800 | [diff] [blame] | 23 | import android.annotation.TestApi; |
Artur Satayev | 54af4fc | 2019-12-10 17:47:56 +0000 | [diff] [blame] | 24 | import android.compat.annotation.UnsupportedAppUsage; |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 25 | import android.content.Intent; |
chen xu | f513b52 | 2018-10-18 16:52:40 -0700 | [diff] [blame] | 26 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.os.Bundle; |
| 28 | import android.os.Parcel; |
| 29 | import android.os.Parcelable; |
Jack Yu | 677cfaa2 | 2018-01-31 00:33:20 -0800 | [diff] [blame] | 30 | import android.telephony.AccessNetworkConstants.AccessNetworkType; |
Jack Yu | ef25faf | 2019-03-14 15:42:09 -0700 | [diff] [blame] | 31 | import android.telephony.AccessNetworkConstants.TransportType; |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 32 | import android.telephony.Annotation.NetworkType; |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 33 | import android.telephony.NetworkRegistrationInfo.Domain; |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 34 | import android.telephony.NetworkRegistrationInfo.NRState; |
Zoran Jovanovic | 47495eb | 2016-11-02 09:56:38 +0100 | [diff] [blame] | 35 | import android.text.TextUtils; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | |
Sarah Chin | 96169ca | 2020-01-07 17:45:05 -0800 | [diff] [blame] | 37 | import com.android.telephony.Rlog; |
| 38 | |
Cassie | d53df96 | 2017-12-05 13:34:33 -0800 | [diff] [blame] | 39 | import java.lang.annotation.Retention; |
| 40 | import java.lang.annotation.RetentionPolicy; |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 41 | import java.util.ArrayList; |
Jack Yu | 677cfaa2 | 2018-01-31 00:33:20 -0800 | [diff] [blame] | 42 | import java.util.Arrays; |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 43 | import java.util.List; |
Nathan Harold | b220fde | 2018-06-27 17:07:52 -0700 | [diff] [blame] | 44 | import java.util.Objects; |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 45 | import java.util.stream.Collectors; |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 46 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | /** |
| 48 | * Contains phone state and service related information. |
| 49 | * |
| 50 | * The following phone information is included in returned ServiceState: |
| 51 | * |
| 52 | * <ul> |
| 53 | * <li>Service state: IN_SERVICE, OUT_OF_SERVICE, EMERGENCY_ONLY, POWER_OFF |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 54 | * <li>Duplex mode: UNKNOWN, FDD, TDD |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | * <li>Roaming indicator |
| 56 | * <li>Operator name, short name and numeric id |
| 57 | * <li>Network selection mode |
| 58 | * </ul> |
Cody Kesting | 1961871 | 2019-03-15 16:22:08 -0700 | [diff] [blame] | 59 | * |
| 60 | * For historical reasons this class is not declared as final; however, |
| 61 | * it should be treated as though it were final. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | */ |
| 63 | public class ServiceState implements Parcelable { |
| 64 | |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 65 | static final String LOG_TAG = "PHONE"; |
Joe Onorato | a102dd0 | 2016-02-01 17:48:18 -0800 | [diff] [blame] | 66 | static final boolean DBG = false; |
Jack Yu | 87f47e9 | 2016-01-05 15:50:40 -0800 | [diff] [blame] | 67 | static final boolean VDBG = false; // STOPSHIP if true |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 68 | |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 69 | /** @hide */ |
| 70 | @Retention(RetentionPolicy.SOURCE) |
| 71 | @IntDef(prefix = "STATE_", |
| 72 | value = {STATE_IN_SERVICE, STATE_OUT_OF_SERVICE, STATE_EMERGENCY_ONLY, |
| 73 | STATE_POWER_OFF}) |
| 74 | public @interface RegState {} |
| 75 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | /** |
| 77 | * Normal operation condition, the phone is registered |
| 78 | * with an operator either in home network or in roaming. |
| 79 | */ |
Yangster | 4ccebea | 2018-10-09 17:09:02 -0700 | [diff] [blame] | 80 | public static final int STATE_IN_SERVICE = TelephonyProtoEnums.SERVICE_STATE_IN_SERVICE; // 0 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * Phone is not registered with any operator, the phone |
| 84 | * can be currently searching a new operator to register to, or not |
| 85 | * searching to registration at all, or registration is denied, or radio |
| 86 | * signal is not available. |
| 87 | */ |
Yangster | 4ccebea | 2018-10-09 17:09:02 -0700 | [diff] [blame] | 88 | public static final int STATE_OUT_OF_SERVICE = |
| 89 | TelephonyProtoEnums.SERVICE_STATE_OUT_OF_SERVICE; // 1 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * The phone is registered and locked. Only emergency numbers are allowed. {@more} |
| 93 | */ |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 94 | //TODO: This state is not used anymore. It should be deprecated in a future release. |
Yangster | 4ccebea | 2018-10-09 17:09:02 -0700 | [diff] [blame] | 95 | public static final int STATE_EMERGENCY_ONLY = |
| 96 | TelephonyProtoEnums.SERVICE_STATE_EMERGENCY_ONLY; // 2 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 97 | |
| 98 | /** |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 99 | * Radio of telephony is explicitly powered off. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | */ |
Yangster | 4ccebea | 2018-10-09 17:09:02 -0700 | [diff] [blame] | 101 | public static final int STATE_POWER_OFF = TelephonyProtoEnums.SERVICE_STATE_POWER_OFF; // 3 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 103 | /** @hide */ |
| 104 | @Retention(RetentionPolicy.SOURCE) |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 105 | @IntDef(prefix = "FREQUENCY_RANGE_", |
| 106 | value = {FREQUENCY_RANGE_UNKNOWN, FREQUENCY_RANGE_LOW, FREQUENCY_RANGE_MID, |
| 107 | FREQUENCY_RANGE_HIGH, FREQUENCY_RANGE_MMWAVE}) |
| 108 | public @interface FrequencyRange {} |
| 109 | |
| 110 | /** |
| 111 | * Indicates frequency range is unknown. |
| 112 | * @hide |
| 113 | */ |
Sarah Chin | 65277df | 2019-10-17 14:59:59 -0700 | [diff] [blame] | 114 | public static final int FREQUENCY_RANGE_UNKNOWN = 0; |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 115 | |
| 116 | /** |
| 117 | * Indicates the frequency range is below 1GHz. |
| 118 | * @hide |
| 119 | */ |
| 120 | public static final int FREQUENCY_RANGE_LOW = 1; |
| 121 | |
| 122 | /** |
| 123 | * Indicates the frequency range is between 1GHz to 3GHz. |
| 124 | * @hide |
| 125 | */ |
| 126 | public static final int FREQUENCY_RANGE_MID = 2; |
| 127 | |
| 128 | /** |
| 129 | * Indicates the frequency range is between 3GHz and 6GHz. |
| 130 | * @hide |
| 131 | */ |
| 132 | public static final int FREQUENCY_RANGE_HIGH = 3; |
| 133 | |
| 134 | /** |
| 135 | * Indicates the frequency range is above 6GHz (millimeter wave frequency). |
| 136 | * @hide |
| 137 | */ |
| 138 | public static final int FREQUENCY_RANGE_MMWAVE = 4; |
| 139 | |
Pengquan Meng | 424acc7 | 2018-11-27 16:45:17 -0800 | [diff] [blame] | 140 | private static final List<Integer> FREQUENCY_RANGE_ORDER = Arrays.asList( |
| 141 | FREQUENCY_RANGE_UNKNOWN, |
| 142 | FREQUENCY_RANGE_LOW, |
| 143 | FREQUENCY_RANGE_MID, |
| 144 | FREQUENCY_RANGE_HIGH, |
| 145 | FREQUENCY_RANGE_MMWAVE); |
| 146 | |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 147 | /** @hide */ |
| 148 | @Retention(RetentionPolicy.SOURCE) |
| 149 | @IntDef(prefix = "DUPLEX_MODE_", |
| 150 | value = {DUPLEX_MODE_UNKNOWN, DUPLEX_MODE_FDD, DUPLEX_MODE_TDD}) |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 151 | public @interface DuplexMode {} |
| 152 | |
| 153 | /** |
| 154 | * Duplex mode for the phone is unknown. |
| 155 | */ |
| 156 | public static final int DUPLEX_MODE_UNKNOWN = 0; |
| 157 | |
| 158 | /** |
| 159 | * Duplex mode for the phone is frequency-division duplexing. |
| 160 | */ |
| 161 | public static final int DUPLEX_MODE_FDD = 1; |
| 162 | |
| 163 | /** |
| 164 | * Duplex mode for the phone is time-division duplexing. |
| 165 | */ |
| 166 | public static final int DUPLEX_MODE_TDD = 2; |
| 167 | |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 168 | /** |
| 169 | * Available radio technologies for GSM, UMTS and CDMA. |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 170 | * Duplicates the constants from hardware/radio/include/ril.h |
| 171 | * This should only be used by agents working with the ril. Others |
| 172 | * should use the equivalent TelephonyManager.NETWORK_TYPE_* |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 173 | */ |
| 174 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 175 | public static final int RIL_RADIO_TECHNOLOGY_UNKNOWN = 0; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 176 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 177 | public static final int RIL_RADIO_TECHNOLOGY_GPRS = 1; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 178 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 179 | public static final int RIL_RADIO_TECHNOLOGY_EDGE = 2; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 180 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 181 | public static final int RIL_RADIO_TECHNOLOGY_UMTS = 3; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 182 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 183 | public static final int RIL_RADIO_TECHNOLOGY_IS95A = 4; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 184 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 185 | public static final int RIL_RADIO_TECHNOLOGY_IS95B = 5; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 186 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 187 | public static final int RIL_RADIO_TECHNOLOGY_1xRTT = 6; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 188 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 189 | public static final int RIL_RADIO_TECHNOLOGY_EVDO_0 = 7; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 190 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 191 | public static final int RIL_RADIO_TECHNOLOGY_EVDO_A = 8; |
Li Zhe | ebe6634 | 2009-08-14 19:22:16 +0800 | [diff] [blame] | 192 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 193 | public static final int RIL_RADIO_TECHNOLOGY_HSDPA = 9; |
Li Zhe | ebe6634 | 2009-08-14 19:22:16 +0800 | [diff] [blame] | 194 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 195 | public static final int RIL_RADIO_TECHNOLOGY_HSUPA = 10; |
Li Zhe | ebe6634 | 2009-08-14 19:22:16 +0800 | [diff] [blame] | 196 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 197 | public static final int RIL_RADIO_TECHNOLOGY_HSPA = 11; |
Naveen Kalla | 0a5174a | 2010-04-21 14:48:03 -0700 | [diff] [blame] | 198 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 199 | public static final int RIL_RADIO_TECHNOLOGY_EVDO_B = 12; |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 200 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 201 | public static final int RIL_RADIO_TECHNOLOGY_EHRPD = 13; |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 202 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 203 | public static final int RIL_RADIO_TECHNOLOGY_LTE = 14; |
Ramesh Sudini | f572761 | 2011-03-08 15:51:52 -0600 | [diff] [blame] | 204 | /** @hide */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 205 | public static final int RIL_RADIO_TECHNOLOGY_HSPAP = 15; |
Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 206 | /** |
| 207 | * GSM radio technology only supports voice. It does not support data. |
| 208 | * @hide |
| 209 | */ |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 210 | public static final int RIL_RADIO_TECHNOLOGY_GSM = 16; |
Etan Cohen | 6415fba3 | 2014-10-02 11:06:23 -0700 | [diff] [blame] | 211 | /** @hide */ |
| 212 | public static final int RIL_RADIO_TECHNOLOGY_TD_SCDMA = 17; |
Yashdev Singh | bece926 | 2015-02-23 13:04:51 -0800 | [diff] [blame] | 213 | /** |
| 214 | * IWLAN |
| 215 | * @hide |
| 216 | */ |
chen xu | f4c5c6e | 2018-11-18 18:56:00 -0800 | [diff] [blame] | 217 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Yashdev Singh | bece926 | 2015-02-23 13:04:51 -0800 | [diff] [blame] | 218 | public static final int RIL_RADIO_TECHNOLOGY_IWLAN = 18; |
Jack Yu | fa530b4 | 2016-01-04 10:04:34 -0800 | [diff] [blame] | 219 | |
Ajay Nambi | 7965fa4 | 2015-05-14 18:48:33 -0700 | [diff] [blame] | 220 | /** |
| 221 | * LTE_CA |
| 222 | * @hide |
| 223 | */ |
| 224 | public static final int RIL_RADIO_TECHNOLOGY_LTE_CA = 19; |
| 225 | |
Cassie | d53df96 | 2017-12-05 13:34:33 -0800 | [diff] [blame] | 226 | /** |
Pengquan Meng | 6b849c2 | 2018-11-27 19:32:39 -0800 | [diff] [blame] | 227 | * NR(New Radio) 5G. |
| 228 | * @hide |
Cassie | d53df96 | 2017-12-05 13:34:33 -0800 | [diff] [blame] | 229 | */ |
Pengquan Meng | 6b849c2 | 2018-11-27 19:32:39 -0800 | [diff] [blame] | 230 | public static final int RIL_RADIO_TECHNOLOGY_NR = 20; |
| 231 | |
| 232 | /** |
Daniel Bright | d75d534 | 2019-12-20 10:30:18 -0800 | [diff] [blame] | 233 | * RIL Radio Annotation |
| 234 | * @hide |
| 235 | */ |
| 236 | @Retention(RetentionPolicy.SOURCE) |
| 237 | @IntDef(prefix = {"RIL_RADIO_TECHNOLOGY_" }, value = { |
| 238 | ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN, |
| 239 | ServiceState.RIL_RADIO_TECHNOLOGY_GPRS, |
| 240 | ServiceState.RIL_RADIO_TECHNOLOGY_EDGE, |
| 241 | ServiceState.RIL_RADIO_TECHNOLOGY_UMTS, |
| 242 | ServiceState.RIL_RADIO_TECHNOLOGY_IS95A, |
| 243 | ServiceState.RIL_RADIO_TECHNOLOGY_IS95B, |
| 244 | ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT, |
| 245 | ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0, |
| 246 | ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A, |
| 247 | ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA, |
| 248 | ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA, |
| 249 | ServiceState.RIL_RADIO_TECHNOLOGY_HSPA, |
| 250 | ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B, |
| 251 | ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD, |
| 252 | ServiceState.RIL_RADIO_TECHNOLOGY_LTE, |
| 253 | ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP, |
| 254 | ServiceState.RIL_RADIO_TECHNOLOGY_GSM, |
| 255 | ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA, |
| 256 | ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN, |
| 257 | ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA, |
| 258 | ServiceState.RIL_RADIO_TECHNOLOGY_NR}) |
| 259 | public @interface RilRadioTechnology {} |
| 260 | |
| 261 | |
| 262 | /** |
Pengquan Meng | 6b849c2 | 2018-11-27 19:32:39 -0800 | [diff] [blame] | 263 | * The number of the radio technologies. |
| 264 | */ |
| 265 | private static final int NEXT_RIL_RADIO_TECHNOLOGY = 21; |
Cassie | d53df96 | 2017-12-05 13:34:33 -0800 | [diff] [blame] | 266 | |
Jack Yu | fa530b4 | 2016-01-04 10:04:34 -0800 | [diff] [blame] | 267 | /** @hide */ |
| 268 | public static final int RIL_RADIO_CDMA_TECHNOLOGY_BITMASK = |
| 269 | (1 << (RIL_RADIO_TECHNOLOGY_IS95A - 1)) |
| 270 | | (1 << (RIL_RADIO_TECHNOLOGY_IS95B - 1)) |
| 271 | | (1 << (RIL_RADIO_TECHNOLOGY_1xRTT - 1)) |
| 272 | | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_0 - 1)) |
| 273 | | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_A - 1)) |
| 274 | | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_B - 1)) |
| 275 | | (1 << (RIL_RADIO_TECHNOLOGY_EHRPD - 1)); |
| 276 | |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 277 | private int mVoiceRegState = STATE_OUT_OF_SERVICE; |
| 278 | private int mDataRegState = STATE_OUT_OF_SERVICE; |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 279 | |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 280 | /** @hide */ |
| 281 | @Retention(RetentionPolicy.SOURCE) |
| 282 | @IntDef(prefix = { "ROAMING_TYPE_" }, value = { |
| 283 | ROAMING_TYPE_NOT_ROAMING, |
| 284 | ROAMING_TYPE_UNKNOWN, |
| 285 | ROAMING_TYPE_DOMESTIC, |
| 286 | ROAMING_TYPE_INTERNATIONAL |
| 287 | }) |
| 288 | public @interface RoamingType {} |
chen xu | e6e2a64 | 2018-11-05 15:59:57 -0800 | [diff] [blame] | 289 | |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 290 | /** |
chen xu | e6e2a64 | 2018-11-05 15:59:57 -0800 | [diff] [blame] | 291 | * Not roaming, registered in home network. |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 292 | * @hide |
| 293 | */ |
chen xu | e6e2a64 | 2018-11-05 15:59:57 -0800 | [diff] [blame] | 294 | @SystemApi |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 295 | public static final int ROAMING_TYPE_NOT_ROAMING = 0; |
| 296 | /** |
chen xu | e6e2a64 | 2018-11-05 15:59:57 -0800 | [diff] [blame] | 297 | * registered in a roaming network, but can not tell if it's domestic or international. |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 298 | * @hide |
| 299 | */ |
chen xu | e6e2a64 | 2018-11-05 15:59:57 -0800 | [diff] [blame] | 300 | @SystemApi |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 301 | public static final int ROAMING_TYPE_UNKNOWN = 1; |
| 302 | /** |
chen xu | e6e2a64 | 2018-11-05 15:59:57 -0800 | [diff] [blame] | 303 | * registered in a domestic roaming network |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 304 | * @hide |
| 305 | */ |
chen xu | e6e2a64 | 2018-11-05 15:59:57 -0800 | [diff] [blame] | 306 | @SystemApi |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 307 | public static final int ROAMING_TYPE_DOMESTIC = 2; |
| 308 | /** |
chen xu | e6e2a64 | 2018-11-05 15:59:57 -0800 | [diff] [blame] | 309 | * registered in an international roaming network |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 310 | * @hide |
| 311 | */ |
chen xu | e6e2a64 | 2018-11-05 15:59:57 -0800 | [diff] [blame] | 312 | @SystemApi |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 313 | public static final int ROAMING_TYPE_INTERNATIONAL = 3; |
| 314 | |
Jack Yu | 9cd3b7b | 2018-01-02 15:51:34 -0800 | [diff] [blame] | 315 | /** |
Jack Yu | 2661fac | 2018-03-15 13:51:05 -0700 | [diff] [blame] | 316 | * Unknown ID. Could be returned by {@link #getCdmaNetworkId()} or {@link #getCdmaSystemId()} |
Jack Yu | 9cd3b7b | 2018-01-02 15:51:34 -0800 | [diff] [blame] | 317 | */ |
| 318 | public static final int UNKNOWN_ID = -1; |
| 319 | |
Amit Mahajan | bb61b17 | 2020-01-23 18:00:08 -0800 | [diff] [blame] | 320 | /** |
| 321 | * A parcelable extra used with {@link Intent#ACTION_SERVICE_STATE} representing the service |
| 322 | * state. |
| 323 | * @hide |
| 324 | */ |
| 325 | private static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE"; |
| 326 | |
| 327 | |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 328 | private String mOperatorAlphaLong; |
| 329 | private String mOperatorAlphaShort; |
| 330 | private String mOperatorNumeric; |
Chen Xu | 4c0b06d | 2018-10-22 16:54:39 +0000 | [diff] [blame] | 331 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 332 | private boolean mIsManualNetworkSelection; |
| 333 | |
John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 334 | private boolean mIsEmergencyOnly; |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 335 | |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 336 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 337 | private boolean mCssIndicator; |
Chen Xu | 4c0b06d | 2018-10-22 16:54:39 +0000 | [diff] [blame] | 338 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 339 | private int mNetworkId; |
Chen Xu | 4c0b06d | 2018-10-22 16:54:39 +0000 | [diff] [blame] | 340 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 341 | private int mSystemId; |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 342 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 343 | private int mCdmaRoamingIndicator; |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 344 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 345 | private int mCdmaDefaultRoamingIndicator; |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 346 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 347 | private int mCdmaEriIconIndex; |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 348 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 349 | private int mCdmaEriIconMode; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 350 | |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 351 | @FrequencyRange |
| 352 | private int mNrFrequencyRange; |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 353 | private int mChannelNumber; |
| 354 | private int[] mCellBandwidths = new int[0]; |
| 355 | |
Sooraj Sasindran | c5659ca | 2017-03-08 23:43:17 -0800 | [diff] [blame] | 356 | /* EARFCN stands for E-UTRA Absolute Radio Frequency Channel Number, |
| 357 | * Reference: 3GPP TS 36.104 5.4.3 */ |
| 358 | private int mLteEarfcnRsrpBoost = 0; |
| 359 | |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 360 | private final List<NetworkRegistrationInfo> mNetworkRegistrationInfos = new ArrayList<>(); |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 361 | |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 362 | private String mOperatorAlphaLongRaw; |
| 363 | private String mOperatorAlphaShortRaw; |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 364 | private boolean mIsDataRoamingFromRegistration; |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 365 | private boolean mIsIwlanPreferred; |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 366 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 367 | /** |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 368 | * get String description of roaming type |
| 369 | * @hide |
| 370 | */ |
| 371 | public static final String getRoamingLogString(int roamingType) { |
| 372 | switch (roamingType) { |
| 373 | case ROAMING_TYPE_NOT_ROAMING: |
| 374 | return "home"; |
| 375 | |
| 376 | case ROAMING_TYPE_UNKNOWN: |
| 377 | return "roaming"; |
| 378 | |
| 379 | case ROAMING_TYPE_DOMESTIC: |
| 380 | return "Domestic Roaming"; |
| 381 | |
| 382 | case ROAMING_TYPE_INTERNATIONAL: |
| 383 | return "International Roaming"; |
| 384 | |
| 385 | default: |
| 386 | return "UNKNOWN"; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 391 | * Create a new ServiceState from a intent notifier Bundle |
| 392 | * |
Malcolm Chen | 8a8b120 | 2019-12-27 16:49:44 -0800 | [diff] [blame] | 393 | * This method is used to get ServiceState object from extras upon receiving |
| 394 | * {@link Intent#ACTION_SERVICE_STATE}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 395 | * |
| 396 | * @param m Bundle from intent notifier |
| 397 | * @return newly created ServiceState |
| 398 | * @hide |
| 399 | */ |
Jordan Liu | 657ef5a | 2019-08-16 14:07:03 -0700 | [diff] [blame] | 400 | @NonNull |
Malcolm Chen | 9993fd6 | 2020-04-28 16:14:01 -0700 | [diff] [blame] | 401 | @UnsupportedAppUsage |
Jordan Liu | 657ef5a | 2019-08-16 14:07:03 -0700 | [diff] [blame] | 402 | public static ServiceState newFromBundle(@NonNull Bundle m) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 403 | ServiceState ret; |
| 404 | ret = new ServiceState(); |
| 405 | ret.setFromNotifierBundle(m); |
| 406 | return ret; |
| 407 | } |
| 408 | |
| 409 | /** |
| 410 | * Empty constructor |
| 411 | */ |
| 412 | public ServiceState() { |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Copy constructors |
| 417 | * |
| 418 | * @param s Source service state |
| 419 | */ |
| 420 | public ServiceState(ServiceState s) { |
| 421 | copyFrom(s); |
| 422 | } |
| 423 | |
| 424 | protected void copyFrom(ServiceState s) { |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 425 | mVoiceRegState = s.mVoiceRegState; |
| 426 | mDataRegState = s.mDataRegState; |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 427 | mOperatorAlphaLong = s.mOperatorAlphaLong; |
| 428 | mOperatorAlphaShort = s.mOperatorAlphaShort; |
| 429 | mOperatorNumeric = s.mOperatorNumeric; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 430 | mIsManualNetworkSelection = s.mIsManualNetworkSelection; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 431 | mCssIndicator = s.mCssIndicator; |
| 432 | mNetworkId = s.mNetworkId; |
| 433 | mSystemId = s.mSystemId; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 434 | mCdmaRoamingIndicator = s.mCdmaRoamingIndicator; |
| 435 | mCdmaDefaultRoamingIndicator = s.mCdmaDefaultRoamingIndicator; |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 436 | mCdmaEriIconIndex = s.mCdmaEriIconIndex; |
| 437 | mCdmaEriIconMode = s.mCdmaEriIconMode; |
John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 438 | mIsEmergencyOnly = s.mIsEmergencyOnly; |
Jack Yu | 7d20eae | 2018-02-22 14:24:16 -0800 | [diff] [blame] | 439 | mChannelNumber = s.mChannelNumber; |
yifan.bai | 257be47 | 2018-08-21 13:42:58 +0800 | [diff] [blame] | 440 | mCellBandwidths = s.mCellBandwidths == null ? null : |
| 441 | Arrays.copyOf(s.mCellBandwidths, s.mCellBandwidths.length); |
Sooraj Sasindran | c5659ca | 2017-03-08 23:43:17 -0800 | [diff] [blame] | 442 | mLteEarfcnRsrpBoost = s.mLteEarfcnRsrpBoost; |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 443 | synchronized (mNetworkRegistrationInfos) { |
| 444 | mNetworkRegistrationInfos.clear(); |
| 445 | mNetworkRegistrationInfos.addAll(s.getNetworkRegistrationInfoList()); |
| 446 | } |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 447 | mNrFrequencyRange = s.mNrFrequencyRange; |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 448 | mOperatorAlphaLongRaw = s.mOperatorAlphaLongRaw; |
| 449 | mOperatorAlphaShortRaw = s.mOperatorAlphaShortRaw; |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 450 | mIsDataRoamingFromRegistration = s.mIsDataRoamingFromRegistration; |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 451 | mIsIwlanPreferred = s.mIsIwlanPreferred; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Construct a ServiceState object from the given parcel. |
Jack Yu | 6bd48a2 | 2019-03-01 14:52:59 -0800 | [diff] [blame] | 456 | * |
| 457 | * @deprecated The constructor takes parcel should not be public at the beginning. Use |
| 458 | * {@link #ServiceState()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 459 | */ |
Jack Yu | 6bd48a2 | 2019-03-01 14:52:59 -0800 | [diff] [blame] | 460 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 461 | public ServiceState(Parcel in) { |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 462 | mVoiceRegState = in.readInt(); |
| 463 | mDataRegState = in.readInt(); |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 464 | mOperatorAlphaLong = in.readString(); |
| 465 | mOperatorAlphaShort = in.readString(); |
| 466 | mOperatorNumeric = in.readString(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 467 | mIsManualNetworkSelection = in.readInt() != 0; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 468 | mCssIndicator = (in.readInt() != 0); |
| 469 | mNetworkId = in.readInt(); |
| 470 | mSystemId = in.readInt(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 471 | mCdmaRoamingIndicator = in.readInt(); |
| 472 | mCdmaDefaultRoamingIndicator = in.readInt(); |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 473 | mCdmaEriIconIndex = in.readInt(); |
| 474 | mCdmaEriIconMode = in.readInt(); |
John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 475 | mIsEmergencyOnly = in.readInt() != 0; |
Sooraj Sasindran | c5659ca | 2017-03-08 23:43:17 -0800 | [diff] [blame] | 476 | mLteEarfcnRsrpBoost = in.readInt(); |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 477 | synchronized (mNetworkRegistrationInfos) { |
| 478 | in.readList(mNetworkRegistrationInfos, NetworkRegistrationInfo.class.getClassLoader()); |
| 479 | } |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 480 | mChannelNumber = in.readInt(); |
| 481 | mCellBandwidths = in.createIntArray(); |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 482 | mNrFrequencyRange = in.readInt(); |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 483 | mOperatorAlphaLongRaw = in.readString(); |
| 484 | mOperatorAlphaShortRaw = in.readString(); |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 485 | mIsDataRoamingFromRegistration = in.readBoolean(); |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 486 | mIsIwlanPreferred = in.readBoolean(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | public void writeToParcel(Parcel out, int flags) { |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 490 | out.writeInt(mVoiceRegState); |
| 491 | out.writeInt(mDataRegState); |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 492 | out.writeString(mOperatorAlphaLong); |
| 493 | out.writeString(mOperatorAlphaShort); |
| 494 | out.writeString(mOperatorNumeric); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 495 | out.writeInt(mIsManualNetworkSelection ? 1 : 0); |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 496 | out.writeInt(mCssIndicator ? 1 : 0); |
| 497 | out.writeInt(mNetworkId); |
| 498 | out.writeInt(mSystemId); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 499 | out.writeInt(mCdmaRoamingIndicator); |
| 500 | out.writeInt(mCdmaDefaultRoamingIndicator); |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 501 | out.writeInt(mCdmaEriIconIndex); |
| 502 | out.writeInt(mCdmaEriIconMode); |
John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 503 | out.writeInt(mIsEmergencyOnly ? 1 : 0); |
Sooraj Sasindran | c5659ca | 2017-03-08 23:43:17 -0800 | [diff] [blame] | 504 | out.writeInt(mLteEarfcnRsrpBoost); |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 505 | synchronized (mNetworkRegistrationInfos) { |
| 506 | out.writeList(mNetworkRegistrationInfos); |
| 507 | } |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 508 | out.writeInt(mChannelNumber); |
| 509 | out.writeIntArray(mCellBandwidths); |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 510 | out.writeInt(mNrFrequencyRange); |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 511 | out.writeString(mOperatorAlphaLongRaw); |
| 512 | out.writeString(mOperatorAlphaShortRaw); |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 513 | out.writeBoolean(mIsDataRoamingFromRegistration); |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 514 | out.writeBoolean(mIsIwlanPreferred); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | public int describeContents() { |
| 518 | return 0; |
| 519 | } |
| 520 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 521 | public static final @android.annotation.NonNull Parcelable.Creator<ServiceState> CREATOR = |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 522 | new Parcelable.Creator<ServiceState>() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 523 | public ServiceState createFromParcel(Parcel in) { |
| 524 | return new ServiceState(in); |
| 525 | } |
| 526 | |
| 527 | public ServiceState[] newArray(int size) { |
| 528 | return new ServiceState[size]; |
| 529 | } |
| 530 | }; |
| 531 | |
| 532 | /** |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 533 | * Get current voice service state |
| 534 | */ |
| 535 | public int getState() { |
| 536 | return getVoiceRegState(); |
| 537 | } |
| 538 | |
| 539 | /** |
| 540 | * Get current voice service state |
Wink Saville | b690ac3 | 2012-11-14 17:03:01 -0800 | [diff] [blame] | 541 | * |
Wink Saville | 69e2522 | 2012-11-15 15:16:45 -0800 | [diff] [blame] | 542 | * @see #STATE_IN_SERVICE |
| 543 | * @see #STATE_OUT_OF_SERVICE |
| 544 | * @see #STATE_EMERGENCY_ONLY |
| 545 | * @see #STATE_POWER_OFF |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 546 | * |
| 547 | * @hide |
Wink Saville | b690ac3 | 2012-11-14 17:03:01 -0800 | [diff] [blame] | 548 | */ |
Chen Xu | 4c0b06d | 2018-10-22 16:54:39 +0000 | [diff] [blame] | 549 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 550 | public int getVoiceRegState() { |
| 551 | return mVoiceRegState; |
| 552 | } |
| 553 | |
| 554 | /** |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 555 | * Get current data registration state. |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 556 | * |
| 557 | * @see #STATE_IN_SERVICE |
| 558 | * @see #STATE_OUT_OF_SERVICE |
| 559 | * @see #STATE_EMERGENCY_ONLY |
| 560 | * @see #STATE_POWER_OFF |
| 561 | * |
SongFerngWang | d82fbaf | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 562 | * @return current data registration state |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 563 | * |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 564 | * @hide |
| 565 | */ |
chen xu | 75355b3 | 2019-01-29 15:56:40 -0800 | [diff] [blame] | 566 | @UnsupportedAppUsage |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 567 | public int getDataRegState() { |
| 568 | return mDataRegState; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | /** |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 572 | * Get current data registration state. |
| 573 | * |
| 574 | * @see #STATE_IN_SERVICE |
| 575 | * @see #STATE_OUT_OF_SERVICE |
| 576 | * @see #STATE_EMERGENCY_ONLY |
| 577 | * @see #STATE_POWER_OFF |
| 578 | * |
SongFerngWang | d82fbaf | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 579 | * @return current data registration state |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 580 | * |
| 581 | * @hide |
| 582 | */ |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 583 | public @RegState int getDataRegistrationState() { |
| 584 | return getDataRegState(); |
| 585 | } |
| 586 | |
| 587 | /** |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 588 | * Get the current duplex mode |
| 589 | * |
| 590 | * @see #DUPLEX_MODE_UNKNOWN |
| 591 | * @see #DUPLEX_MODE_FDD |
| 592 | * @see #DUPLEX_MODE_TDD |
| 593 | * |
| 594 | * @return Current {@code DuplexMode} for the phone |
| 595 | */ |
| 596 | @DuplexMode |
| 597 | public int getDuplexMode() { |
Sarah Chin | 96169ca | 2020-01-07 17:45:05 -0800 | [diff] [blame] | 598 | // support LTE/NR duplex mode |
| 599 | if (!isPsOnlyTech(getRilDataRadioTechnology())) { |
Eric Schwarzenbach | 2c1a177 | 2018-03-02 17:47:13 -0800 | [diff] [blame] | 600 | return DUPLEX_MODE_UNKNOWN; |
| 601 | } |
| 602 | |
| 603 | int band = AccessNetworkUtils.getOperatingBandForEarfcn(mChannelNumber); |
| 604 | return AccessNetworkUtils.getDuplexModeForEutranBand(band); |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | /** |
| 608 | * Get the channel number of the current primary serving cell, or -1 if unknown |
| 609 | * |
| 610 | * <p>This is EARFCN for LTE, UARFCN for UMTS, and ARFCN for GSM. |
| 611 | * |
| 612 | * @return Channel number of primary serving cell |
| 613 | */ |
| 614 | public int getChannelNumber() { |
| 615 | return mChannelNumber; |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * Get an array of cell bandwidths (kHz) for the current serving cells |
| 620 | * |
| 621 | * @return Current serving cell bandwidths |
| 622 | */ |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 623 | public int[] getCellBandwidths() { |
Eric Schwarzenbach | c119a86 | 2018-03-22 13:49:25 -0700 | [diff] [blame] | 624 | return mCellBandwidths == null ? new int[0] : mCellBandwidths; |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 628 | * Get current roaming indicator of phone |
| 629 | * (note: not just decoding from TS 27.007 7.2) |
| 630 | * |
| 631 | * @return true if TS 27.007 7.2 roaming is true |
| 632 | * and ONS is different from SPN |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 633 | */ |
| 634 | public boolean getRoaming() { |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 635 | return getVoiceRoaming() || getDataRoaming(); |
| 636 | } |
| 637 | |
| 638 | /** |
| 639 | * Get current voice network roaming status |
| 640 | * @return roaming status |
| 641 | * @hide |
| 642 | */ |
Chen Xu | 4c0b06d | 2018-10-22 16:54:39 +0000 | [diff] [blame] | 643 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 644 | public boolean getVoiceRoaming() { |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 645 | return getVoiceRoamingType() != ROAMING_TYPE_NOT_ROAMING; |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 646 | } |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 647 | /** |
| 648 | * Get current voice network roaming type |
| 649 | * @return roaming type |
| 650 | * @hide |
| 651 | */ |
chen xu | f4c5c6e | 2018-11-18 18:56:00 -0800 | [diff] [blame] | 652 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 653 | public @RoamingType int getVoiceRoamingType() { |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 654 | final NetworkRegistrationInfo regState = getNetworkRegistrationInfo( |
| 655 | NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 656 | if (regState != null) { |
| 657 | return regState.getRoamingType(); |
| 658 | } |
| 659 | return ROAMING_TYPE_NOT_ROAMING; |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | /** |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 663 | * Get whether the current data network is roaming. |
| 664 | * This value may be overwritten by resource overlay or carrier configuration. |
| 665 | * @see #getDataRoamingFromRegistration() to get the value from the network registration. |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 666 | * @return roaming type |
| 667 | * @hide |
| 668 | */ |
Chen Xu | 4c0b06d | 2018-10-22 16:54:39 +0000 | [diff] [blame] | 669 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 670 | public boolean getDataRoaming() { |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 671 | return getDataRoamingType() != ROAMING_TYPE_NOT_ROAMING; |
Chris Manton | 1428f43 | 2015-08-10 13:32:24 -0700 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | /** |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 675 | * Set whether the data network registration state is roaming. |
| 676 | * This should only be set to the roaming value received |
| 677 | * once the data registration phase has completed. |
| 678 | * @hide |
| 679 | */ |
| 680 | public void setDataRoamingFromRegistration(boolean dataRoaming) { |
| 681 | mIsDataRoamingFromRegistration = dataRoaming; |
| 682 | } |
| 683 | |
| 684 | /** |
| 685 | * Get whether data network registration state is roaming. |
| 686 | * This value is set directly from the modem and will not be overwritten |
| 687 | * by resource overlay or carrier configuration. |
Chris Manton | 1428f43 | 2015-08-10 13:32:24 -0700 | [diff] [blame] | 688 | * @return true if registration indicates roaming, false otherwise |
| 689 | * @hide |
| 690 | */ |
| 691 | public boolean getDataRoamingFromRegistration() { |
Sarah Chin | ba01f23 | 2020-03-10 11:46:42 -0700 | [diff] [blame] | 692 | // TODO: all callers should refactor to get roaming state directly from modem |
| 693 | // this should not be exposed as a public API |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 694 | return mIsDataRoamingFromRegistration; |
Chris Manton | 1428f43 | 2015-08-10 13:32:24 -0700 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | /** |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 698 | * Get current data network roaming type |
| 699 | * @return roaming type |
| 700 | * @hide |
| 701 | */ |
chen xu | f4c5c6e | 2018-11-18 18:56:00 -0800 | [diff] [blame] | 702 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 703 | public @RoamingType int getDataRoamingType() { |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 704 | final NetworkRegistrationInfo regState = getNetworkRegistrationInfo( |
| 705 | NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 706 | if (regState != null) { |
| 707 | return regState.getRoamingType(); |
| 708 | } |
| 709 | return ROAMING_TYPE_NOT_ROAMING; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 710 | } |
| 711 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 712 | /** |
| 713 | * @hide |
| 714 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 715 | @UnsupportedAppUsage |
John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 716 | public boolean isEmergencyOnly() { |
| 717 | return mIsEmergencyOnly; |
| 718 | } |
| 719 | |
| 720 | /** |
| 721 | * @hide |
| 722 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 723 | @UnsupportedAppUsage |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 724 | public int getCdmaRoamingIndicator(){ |
| 725 | return this.mCdmaRoamingIndicator; |
| 726 | } |
| 727 | |
| 728 | /** |
| 729 | * @hide |
| 730 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 731 | @UnsupportedAppUsage |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 732 | public int getCdmaDefaultRoamingIndicator(){ |
| 733 | return this.mCdmaDefaultRoamingIndicator; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 734 | } |
| 735 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 736 | /** |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 737 | * @hide |
| 738 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 739 | @UnsupportedAppUsage |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 740 | public int getCdmaEriIconIndex() { |
| 741 | return this.mCdmaEriIconIndex; |
| 742 | } |
| 743 | |
| 744 | /** |
| 745 | * @hide |
| 746 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 747 | @UnsupportedAppUsage |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 748 | public int getCdmaEriIconMode() { |
| 749 | return this.mCdmaEriIconMode; |
| 750 | } |
| 751 | |
| 752 | /** |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 753 | * Get current registered operator name in long alphanumeric format. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 754 | * |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 755 | * In GSM/UMTS, long format can be up to 16 characters long. |
| 756 | * In CDMA, returns the ERI text, if set. Otherwise, returns the ONS. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 757 | * |
| 758 | * @return long name of operator, null if unregistered or unknown |
| 759 | */ |
| 760 | public String getOperatorAlphaLong() { |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 761 | return mOperatorAlphaLong; |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 762 | } |
| 763 | |
| 764 | /** |
| 765 | * Get current registered voice network operator name in long alphanumeric format. |
| 766 | * @return long name of operator |
| 767 | * @hide |
| 768 | */ |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 769 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, |
| 770 | publicAlternatives = "Use {@link #getOperatorAlphaLong} instead.") |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 771 | public String getVoiceOperatorAlphaLong() { |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 772 | return mOperatorAlphaLong; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | /** |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 776 | * Get current registered operator name in short alphanumeric format. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 777 | * |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 778 | * In GSM/UMTS, short format can be up to 8 characters long. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 779 | * |
| 780 | * @return short name of operator, null if unregistered or unknown |
| 781 | */ |
| 782 | public String getOperatorAlphaShort() { |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 783 | return mOperatorAlphaShort; |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | /** |
| 787 | * Get current registered voice network operator name in short alphanumeric format. |
| 788 | * @return short name of operator, null if unregistered or unknown |
| 789 | * @hide |
| 790 | */ |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 791 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, |
| 792 | publicAlternatives = "Use {@link #getOperatorAlphaShort} instead.") |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 793 | public String getVoiceOperatorAlphaShort() { |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 794 | return mOperatorAlphaShort; |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 795 | } |
| 796 | |
| 797 | /** |
| 798 | * Get current registered data network operator name in short alphanumeric format. |
| 799 | * @return short name of operator, null if unregistered or unknown |
| 800 | * @hide |
| 801 | */ |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 802 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, |
| 803 | publicAlternatives = "Use {@link #getOperatorAlphaShort} instead.") |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 804 | public String getDataOperatorAlphaShort() { |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 805 | return mOperatorAlphaShort; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 806 | } |
| 807 | |
| 808 | /** |
Zoran Jovanovic | 47495eb | 2016-11-02 09:56:38 +0100 | [diff] [blame] | 809 | * Get current registered operator name in long alphanumeric format if |
| 810 | * available or short otherwise. |
| 811 | * |
| 812 | * @see #getOperatorAlphaLong |
| 813 | * @see #getOperatorAlphaShort |
| 814 | * |
| 815 | * @return name of operator, null if unregistered or unknown |
| 816 | * @hide |
| 817 | */ |
| 818 | public String getOperatorAlpha() { |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 819 | if (TextUtils.isEmpty(mOperatorAlphaLong)) { |
| 820 | return mOperatorAlphaShort; |
Zoran Jovanovic | 47495eb | 2016-11-02 09:56:38 +0100 | [diff] [blame] | 821 | } |
| 822 | |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 823 | return mOperatorAlphaLong; |
Zoran Jovanovic | 47495eb | 2016-11-02 09:56:38 +0100 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | /** |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 827 | * Get current registered operator numeric id. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 828 | * |
| 829 | * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 830 | * network code. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 831 | * |
| 832 | * @return numeric format of operator, null if unregistered or unknown |
| 833 | */ |
Jean-Baptiste Queru | e25863c | 2010-05-18 11:54:42 -0700 | [diff] [blame] | 834 | /* |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 835 | * The country code can be decoded using |
| 836 | * {@link com.android.internal.telephony.MccTable#countryCodeForMcc(int)}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 837 | */ |
| 838 | public String getOperatorNumeric() { |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 839 | return mOperatorNumeric; |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 840 | } |
| 841 | |
| 842 | /** |
| 843 | * Get current registered voice network operator numeric id. |
| 844 | * @return numeric format of operator, null if unregistered or unknown |
| 845 | * @hide |
| 846 | */ |
chen xu | f4c5c6e | 2018-11-18 18:56:00 -0800 | [diff] [blame] | 847 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 848 | public String getVoiceOperatorNumeric() { |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 849 | return mOperatorNumeric; |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | /** |
| 853 | * Get current registered data network operator numeric id. |
| 854 | * @return numeric format of operator, null if unregistered or unknown |
| 855 | * @hide |
| 856 | */ |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 857 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, |
| 858 | publicAlternatives = "Use {@link #getOperatorNumeric} instead.") |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 859 | public String getDataOperatorNumeric() { |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 860 | return mOperatorNumeric; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 861 | } |
| 862 | |
| 863 | /** |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 864 | * Get current network selection mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 865 | * |
| 866 | * @return true if manual mode, false if automatic mode |
| 867 | */ |
| 868 | public boolean getIsManualSelection() { |
| 869 | return mIsManualNetworkSelection; |
| 870 | } |
| 871 | |
| 872 | @Override |
| 873 | public int hashCode() { |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 874 | synchronized (mNetworkRegistrationInfos) { |
| 875 | return Objects.hash( |
| 876 | mVoiceRegState, |
| 877 | mDataRegState, |
| 878 | mChannelNumber, |
| 879 | Arrays.hashCode(mCellBandwidths), |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 880 | mOperatorAlphaLong, |
| 881 | mOperatorAlphaShort, |
| 882 | mOperatorNumeric, |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 883 | mIsManualNetworkSelection, |
| 884 | mCssIndicator, |
| 885 | mNetworkId, |
| 886 | mSystemId, |
| 887 | mCdmaRoamingIndicator, |
| 888 | mCdmaDefaultRoamingIndicator, |
| 889 | mCdmaEriIconIndex, |
| 890 | mCdmaEriIconMode, |
| 891 | mIsEmergencyOnly, |
| 892 | mLteEarfcnRsrpBoost, |
| 893 | mNetworkRegistrationInfos, |
| 894 | mNrFrequencyRange, |
| 895 | mOperatorAlphaLongRaw, |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 896 | mOperatorAlphaShortRaw, |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 897 | mIsDataRoamingFromRegistration, |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 898 | mIsIwlanPreferred); |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 899 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | @Override |
| 903 | public boolean equals (Object o) { |
Nathan Harold | 7ee5f21 | 2018-06-27 17:21:17 -0700 | [diff] [blame] | 904 | if (!(o instanceof ServiceState)) return false; |
| 905 | ServiceState s = (ServiceState) o; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 906 | |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 907 | synchronized (mNetworkRegistrationInfos) { |
| 908 | return mVoiceRegState == s.mVoiceRegState |
| 909 | && mDataRegState == s.mDataRegState |
| 910 | && mIsManualNetworkSelection == s.mIsManualNetworkSelection |
| 911 | && mChannelNumber == s.mChannelNumber |
| 912 | && Arrays.equals(mCellBandwidths, s.mCellBandwidths) |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 913 | && equalsHandlesNulls(mOperatorAlphaLong, s.mOperatorAlphaLong) |
| 914 | && equalsHandlesNulls(mOperatorAlphaShort, s.mOperatorAlphaShort) |
| 915 | && equalsHandlesNulls(mOperatorNumeric, s.mOperatorNumeric) |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 916 | && equalsHandlesNulls(mCssIndicator, s.mCssIndicator) |
| 917 | && equalsHandlesNulls(mNetworkId, s.mNetworkId) |
| 918 | && equalsHandlesNulls(mSystemId, s.mSystemId) |
| 919 | && equalsHandlesNulls(mCdmaRoamingIndicator, s.mCdmaRoamingIndicator) |
| 920 | && equalsHandlesNulls(mCdmaDefaultRoamingIndicator, |
| 921 | s.mCdmaDefaultRoamingIndicator) |
| 922 | && mIsEmergencyOnly == s.mIsEmergencyOnly |
| 923 | && equalsHandlesNulls(mOperatorAlphaLongRaw, s.mOperatorAlphaLongRaw) |
| 924 | && equalsHandlesNulls(mOperatorAlphaShortRaw, s.mOperatorAlphaShortRaw) |
| 925 | && mNetworkRegistrationInfos.size() == s.mNetworkRegistrationInfos.size() |
| 926 | && mNetworkRegistrationInfos.containsAll(s.mNetworkRegistrationInfos) |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 927 | && mNrFrequencyRange == s.mNrFrequencyRange |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 928 | && mIsDataRoamingFromRegistration == s.mIsDataRoamingFromRegistration |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 929 | && mIsIwlanPreferred == s.mIsIwlanPreferred; |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 930 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 931 | } |
| 932 | |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 933 | /** |
Jack Yu | 8fdb750 | 2019-01-31 13:30:05 -0800 | [diff] [blame] | 934 | * Convert roaming type to string |
| 935 | * |
| 936 | * @param roamingType roaming type |
| 937 | * @return The roaming type in string format |
| 938 | * |
| 939 | * @hide |
| 940 | */ |
| 941 | public static String roamingTypeToString(@RoamingType int roamingType) { |
| 942 | switch (roamingType) { |
| 943 | case ROAMING_TYPE_NOT_ROAMING: return "NOT_ROAMING"; |
| 944 | case ROAMING_TYPE_UNKNOWN: return "UNKNOWN"; |
| 945 | case ROAMING_TYPE_DOMESTIC: return "DOMESTIC"; |
| 946 | case ROAMING_TYPE_INTERNATIONAL: return "INTERNATIONAL"; |
| 947 | } |
| 948 | return "Unknown roaming type " + roamingType; |
| 949 | } |
| 950 | |
| 951 | /** |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 952 | * Convert radio technology to String |
| 953 | * |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 954 | * @param rt radioTechnology |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 955 | * @return String representation of the RAT |
| 956 | * |
| 957 | * @hide |
| 958 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 959 | @UnsupportedAppUsage |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 960 | public static String rilRadioTechnologyToString(int rt) { |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 961 | String rtString; |
| 962 | |
| 963 | switch(rt) { |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 964 | case RIL_RADIO_TECHNOLOGY_UNKNOWN: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 965 | rtString = "Unknown"; |
| 966 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 967 | case RIL_RADIO_TECHNOLOGY_GPRS: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 968 | rtString = "GPRS"; |
| 969 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 970 | case RIL_RADIO_TECHNOLOGY_EDGE: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 971 | rtString = "EDGE"; |
| 972 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 973 | case RIL_RADIO_TECHNOLOGY_UMTS: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 974 | rtString = "UMTS"; |
| 975 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 976 | case RIL_RADIO_TECHNOLOGY_IS95A: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 977 | rtString = "CDMA-IS95A"; |
| 978 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 979 | case RIL_RADIO_TECHNOLOGY_IS95B: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 980 | rtString = "CDMA-IS95B"; |
| 981 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 982 | case RIL_RADIO_TECHNOLOGY_1xRTT: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 983 | rtString = "1xRTT"; |
| 984 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 985 | case RIL_RADIO_TECHNOLOGY_EVDO_0: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 986 | rtString = "EvDo-rev.0"; |
| 987 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 988 | case RIL_RADIO_TECHNOLOGY_EVDO_A: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 989 | rtString = "EvDo-rev.A"; |
| 990 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 991 | case RIL_RADIO_TECHNOLOGY_HSDPA: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 992 | rtString = "HSDPA"; |
| 993 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 994 | case RIL_RADIO_TECHNOLOGY_HSUPA: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 995 | rtString = "HSUPA"; |
| 996 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 997 | case RIL_RADIO_TECHNOLOGY_HSPA: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 998 | rtString = "HSPA"; |
| 999 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 1000 | case RIL_RADIO_TECHNOLOGY_EVDO_B: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 1001 | rtString = "EvDo-rev.B"; |
| 1002 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 1003 | case RIL_RADIO_TECHNOLOGY_EHRPD: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 1004 | rtString = "eHRPD"; |
| 1005 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 1006 | case RIL_RADIO_TECHNOLOGY_LTE: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 1007 | rtString = "LTE"; |
| 1008 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 1009 | case RIL_RADIO_TECHNOLOGY_HSPAP: |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 1010 | rtString = "HSPAP"; |
| 1011 | break; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 1012 | case RIL_RADIO_TECHNOLOGY_GSM: |
Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 1013 | rtString = "GSM"; |
| 1014 | break; |
Yashdev Singh | bece926 | 2015-02-23 13:04:51 -0800 | [diff] [blame] | 1015 | case RIL_RADIO_TECHNOLOGY_IWLAN: |
| 1016 | rtString = "IWLAN"; |
| 1017 | break; |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 1018 | case RIL_RADIO_TECHNOLOGY_TD_SCDMA: |
| 1019 | rtString = "TD-SCDMA"; |
| 1020 | break; |
Ajay Nambi | 7965fa4 | 2015-05-14 18:48:33 -0700 | [diff] [blame] | 1021 | case RIL_RADIO_TECHNOLOGY_LTE_CA: |
| 1022 | rtString = "LTE_CA"; |
| 1023 | break; |
Avinash Nalluri | 61b44a2 | 2019-06-19 19:13:28 -0700 | [diff] [blame] | 1024 | case RIL_RADIO_TECHNOLOGY_NR: |
Sarah Chin | d1941e57 | 2019-12-13 11:12:28 -0800 | [diff] [blame] | 1025 | rtString = "NR_SA"; |
Avinash Nalluri | 61b44a2 | 2019-06-19 19:13:28 -0700 | [diff] [blame] | 1026 | break; |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 1027 | default: |
| 1028 | rtString = "Unexpected"; |
Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 1029 | Rlog.w(LOG_TAG, "Unexpected radioTechnology=" + rt); |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 1030 | break; |
| 1031 | } |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 1032 | return rtString; |
Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 1033 | } |
| 1034 | |
Nathan Harold | 9acfe6f | 2017-08-02 10:51:47 -0700 | [diff] [blame] | 1035 | /** |
Jack Yu | e7580a7 | 2020-06-12 16:05:58 -0700 | [diff] [blame] | 1036 | * Convert frequency range into string |
| 1037 | * |
| 1038 | * @param range The cellular frequency range |
| 1039 | * @return Frequency range in string format |
| 1040 | * |
| 1041 | * @hide |
| 1042 | */ |
| 1043 | public static @NonNull String frequencyRangeToString(@FrequencyRange int range) { |
| 1044 | switch (range) { |
| 1045 | case FREQUENCY_RANGE_UNKNOWN: return "UNKNOWN"; |
| 1046 | case FREQUENCY_RANGE_LOW: return "LOW"; |
| 1047 | case FREQUENCY_RANGE_MID: return "MID"; |
| 1048 | case FREQUENCY_RANGE_HIGH: return "HIGH"; |
| 1049 | case FREQUENCY_RANGE_MMWAVE: return "MMWAVE"; |
| 1050 | default: |
| 1051 | return Integer.toString(range); |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | /** |
Nathan Harold | 9acfe6f | 2017-08-02 10:51:47 -0700 | [diff] [blame] | 1056 | * Convert RIL Service State to String |
| 1057 | * |
| 1058 | * @param serviceState |
| 1059 | * @return String representation of the ServiceState |
| 1060 | * |
| 1061 | * @hide |
| 1062 | */ |
| 1063 | public static String rilServiceStateToString(int serviceState) { |
| 1064 | switch(serviceState) { |
| 1065 | case STATE_IN_SERVICE: |
| 1066 | return "IN_SERVICE"; |
| 1067 | case STATE_OUT_OF_SERVICE: |
| 1068 | return "OUT_OF_SERVICE"; |
| 1069 | case STATE_EMERGENCY_ONLY: |
| 1070 | return "EMERGENCY_ONLY"; |
| 1071 | case STATE_POWER_OFF: |
| 1072 | return "POWER_OFF"; |
| 1073 | default: |
| 1074 | return "UNKNOWN"; |
| 1075 | } |
| 1076 | } |
| 1077 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1078 | @Override |
| 1079 | public String toString() { |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 1080 | synchronized (mNetworkRegistrationInfos) { |
| 1081 | return new StringBuilder().append("{mVoiceRegState=").append(mVoiceRegState) |
| 1082 | .append("(" + rilServiceStateToString(mVoiceRegState) + ")") |
| 1083 | .append(", mDataRegState=").append(mDataRegState) |
| 1084 | .append("(" + rilServiceStateToString(mDataRegState) + ")") |
| 1085 | .append(", mChannelNumber=").append(mChannelNumber) |
| 1086 | .append(", duplexMode()=").append(getDuplexMode()) |
| 1087 | .append(", mCellBandwidths=").append(Arrays.toString(mCellBandwidths)) |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 1088 | .append(", mOperatorAlphaLong=").append(mOperatorAlphaLong) |
| 1089 | .append(", mOperatorAlphaShort=").append(mOperatorAlphaShort) |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 1090 | .append(", isManualNetworkSelection=").append(mIsManualNetworkSelection) |
| 1091 | .append(mIsManualNetworkSelection ? "(manual)" : "(automatic)") |
| 1092 | .append(", getRilVoiceRadioTechnology=").append(getRilVoiceRadioTechnology()) |
| 1093 | .append("(" + rilRadioTechnologyToString(getRilVoiceRadioTechnology()) + ")") |
| 1094 | .append(", getRilDataRadioTechnology=").append(getRilDataRadioTechnology()) |
| 1095 | .append("(" + rilRadioTechnologyToString(getRilDataRadioTechnology()) + ")") |
| 1096 | .append(", mCssIndicator=").append(mCssIndicator ? "supported" : "unsupported") |
| 1097 | .append(", mNetworkId=").append(mNetworkId) |
| 1098 | .append(", mSystemId=").append(mSystemId) |
| 1099 | .append(", mCdmaRoamingIndicator=").append(mCdmaRoamingIndicator) |
| 1100 | .append(", mCdmaDefaultRoamingIndicator=").append(mCdmaDefaultRoamingIndicator) |
| 1101 | .append(", mIsEmergencyOnly=").append(mIsEmergencyOnly) |
| 1102 | .append(", isUsingCarrierAggregation=").append(isUsingCarrierAggregation()) |
| 1103 | .append(", mLteEarfcnRsrpBoost=").append(mLteEarfcnRsrpBoost) |
| 1104 | .append(", mNetworkRegistrationInfos=").append(mNetworkRegistrationInfos) |
| 1105 | .append(", mNrFrequencyRange=").append(mNrFrequencyRange) |
| 1106 | .append(", mOperatorAlphaLongRaw=").append(mOperatorAlphaLongRaw) |
| 1107 | .append(", mOperatorAlphaShortRaw=").append(mOperatorAlphaShortRaw) |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 1108 | .append(", mIsDataRoamingFromRegistration=") |
| 1109 | .append(mIsDataRoamingFromRegistration) |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 1110 | .append(", mIsIwlanPreferred=").append(mIsIwlanPreferred) |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 1111 | .append("}").toString(); |
| 1112 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1113 | } |
| 1114 | |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1115 | private void init() { |
| 1116 | if (DBG) Rlog.d(LOG_TAG, "init"); |
| 1117 | mVoiceRegState = STATE_OUT_OF_SERVICE; |
| 1118 | mDataRegState = STATE_OUT_OF_SERVICE; |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 1119 | mChannelNumber = -1; |
| 1120 | mCellBandwidths = new int[0]; |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 1121 | mOperatorAlphaLong = null; |
| 1122 | mOperatorAlphaShort = null; |
| 1123 | mOperatorNumeric = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1124 | mIsManualNetworkSelection = false; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1125 | mCssIndicator = false; |
| 1126 | mNetworkId = -1; |
| 1127 | mSystemId = -1; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1128 | mCdmaRoamingIndicator = -1; |
| 1129 | mCdmaDefaultRoamingIndicator = -1; |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 1130 | mCdmaEriIconIndex = -1; |
| 1131 | mCdmaEriIconMode = -1; |
John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 1132 | mIsEmergencyOnly = false; |
Sooraj Sasindran | c5659ca | 2017-03-08 23:43:17 -0800 | [diff] [blame] | 1133 | mLteEarfcnRsrpBoost = 0; |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 1134 | mNrFrequencyRange = FREQUENCY_RANGE_UNKNOWN; |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 1135 | synchronized (mNetworkRegistrationInfos) { |
| 1136 | mNetworkRegistrationInfos.clear(); |
| 1137 | addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() |
| 1138 | .setDomain(NetworkRegistrationInfo.DOMAIN_CS) |
| 1139 | .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) |
| 1140 | .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_UNKNOWN) |
| 1141 | .build()); |
| 1142 | addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() |
| 1143 | .setDomain(NetworkRegistrationInfo.DOMAIN_PS) |
| 1144 | .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) |
| 1145 | .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_UNKNOWN) |
| 1146 | .build()); |
| 1147 | } |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 1148 | mOperatorAlphaLongRaw = null; |
| 1149 | mOperatorAlphaShortRaw = null; |
Sarah Chin | d4b4da2 | 2020-01-07 16:32:39 -0800 | [diff] [blame] | 1150 | mIsDataRoamingFromRegistration = false; |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 1151 | mIsIwlanPreferred = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1152 | } |
| 1153 | |
Robert Greenwalt | a226745 | 2011-06-30 12:24:26 -0700 | [diff] [blame] | 1154 | public void setStateOutOfService() { |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1155 | init(); |
Robert Greenwalt | a226745 | 2011-06-30 12:24:26 -0700 | [diff] [blame] | 1156 | } |
| 1157 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1158 | public void setStateOff() { |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1159 | init(); |
| 1160 | mVoiceRegState = STATE_POWER_OFF; |
| 1161 | mDataRegState = STATE_POWER_OFF; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | public void setState(int state) { |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1165 | setVoiceRegState(state); |
Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 1166 | if (DBG) Rlog.e(LOG_TAG, "[ServiceState] setState deprecated use setVoiceRegState()"); |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1167 | } |
| 1168 | |
| 1169 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1170 | @UnsupportedAppUsage |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1171 | public void setVoiceRegState(int state) { |
| 1172 | mVoiceRegState = state; |
Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 1173 | if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setVoiceRegState=" + mVoiceRegState); |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | /** @hide */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 1177 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1178 | public void setDataRegState(int state) { |
| 1179 | mDataRegState = state; |
Jack Yu | 87f47e9 | 2016-01-05 15:50:40 -0800 | [diff] [blame] | 1180 | if (VDBG) Rlog.d(LOG_TAG, "[ServiceState] setDataRegState=" + mDataRegState); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1181 | } |
| 1182 | |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 1183 | /** @hide */ |
Malcolm Chen | a1d5e9f | 2018-04-03 17:43:30 -0700 | [diff] [blame] | 1184 | @TestApi |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 1185 | public void setCellBandwidths(int[] bandwidths) { |
| 1186 | mCellBandwidths = bandwidths; |
| 1187 | } |
| 1188 | |
| 1189 | /** @hide */ |
Malcolm Chen | a1d5e9f | 2018-04-03 17:43:30 -0700 | [diff] [blame] | 1190 | @TestApi |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 1191 | public void setChannelNumber(int channelNumber) { |
| 1192 | mChannelNumber = channelNumber; |
| 1193 | } |
| 1194 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1195 | public void setRoaming(boolean roaming) { |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1196 | setVoiceRoaming(roaming); |
| 1197 | setDataRoaming(roaming); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1198 | } |
| 1199 | |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 1200 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1201 | @UnsupportedAppUsage |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 1202 | public void setVoiceRoaming(boolean roaming) { |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1203 | setVoiceRoamingType(roaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING); |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 1204 | } |
| 1205 | |
| 1206 | /** @hide */ |
Cody Kesting | e19048e | 2019-03-15 11:20:01 -0700 | [diff] [blame] | 1207 | @TestApi |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1208 | public void setVoiceRoamingType(@RoamingType int type) { |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1209 | NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo( |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1210 | NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1211 | if (regInfo == null) { |
| 1212 | regInfo = new NetworkRegistrationInfo.Builder() |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 1213 | .setDomain(NetworkRegistrationInfo.DOMAIN_CS) |
| 1214 | .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) |
| 1215 | .build(); |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1216 | } |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1217 | regInfo.setRoamingType(type); |
| 1218 | addNetworkRegistrationInfo(regInfo); |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 1219 | } |
| 1220 | |
| 1221 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1222 | @UnsupportedAppUsage |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 1223 | public void setDataRoaming(boolean dataRoaming) { |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1224 | setDataRoamingType(dataRoaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING); |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | /** @hide */ |
Cody Kesting | e19048e | 2019-03-15 11:20:01 -0700 | [diff] [blame] | 1228 | @TestApi |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1229 | public void setDataRoamingType(@RoamingType int type) { |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1230 | NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo( |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1231 | NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1232 | if (regInfo == null) { |
| 1233 | regInfo = new NetworkRegistrationInfo.Builder() |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 1234 | .setDomain(NetworkRegistrationInfo.DOMAIN_PS) |
| 1235 | .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) |
| 1236 | .build(); |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1237 | } |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1238 | regInfo.setRoamingType(type); |
| 1239 | addNetworkRegistrationInfo(regInfo); |
Jing Zhao | e6edb16 | 2014-07-18 09:34:36 -0500 | [diff] [blame] | 1240 | } |
John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 1241 | |
| 1242 | /** |
| 1243 | * @hide |
| 1244 | */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 1245 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 1246 | public void setEmergencyOnly(boolean emergencyOnly) { |
| 1247 | mIsEmergencyOnly = emergencyOnly; |
| 1248 | } |
| 1249 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1250 | /** |
| 1251 | * @hide |
| 1252 | */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 1253 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1254 | public void setCdmaRoamingIndicator(int roaming) { |
| 1255 | this.mCdmaRoamingIndicator = roaming; |
| 1256 | } |
| 1257 | |
| 1258 | /** |
| 1259 | * @hide |
| 1260 | */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 1261 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1262 | public void setCdmaDefaultRoamingIndicator (int roaming) { |
| 1263 | this.mCdmaDefaultRoamingIndicator = roaming; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1264 | } |
| 1265 | |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 1266 | /** |
| 1267 | * @hide |
| 1268 | */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 1269 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 1270 | public void setCdmaEriIconIndex(int index) { |
| 1271 | this.mCdmaEriIconIndex = index; |
| 1272 | } |
| 1273 | |
| 1274 | /** |
| 1275 | * @hide |
| 1276 | */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 1277 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 1278 | public void setCdmaEriIconMode(int mode) { |
| 1279 | this.mCdmaEriIconMode = mode; |
| 1280 | } |
| 1281 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1282 | public void setOperatorName(String longName, String shortName, String numeric) { |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 1283 | mOperatorAlphaLong = longName; |
| 1284 | mOperatorAlphaShort = shortName; |
| 1285 | mOperatorNumeric = numeric; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1286 | } |
| 1287 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1288 | /** |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 1289 | * In CDMA, mOperatorAlphaLong can be set from the ERI text. |
Jack Yu | 6714030 | 2015-12-10 12:27:58 -0800 | [diff] [blame] | 1290 | * This is done from the GsmCdmaPhone and not from the ServiceStateTracker. |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1291 | * |
| 1292 | * @hide |
| 1293 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1294 | @UnsupportedAppUsage |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 1295 | public void setOperatorAlphaLong(@Nullable String longName) { |
| 1296 | mOperatorAlphaLong = longName; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1297 | } |
| 1298 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1299 | public void setIsManualSelection(boolean isManual) { |
| 1300 | mIsManualNetworkSelection = isManual; |
| 1301 | } |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1302 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1303 | /** |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 1304 | * Test whether two objects hold the same data values or both are null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1305 | * |
| 1306 | * @param a first obj |
| 1307 | * @param b second obj |
| 1308 | * @return true if two objects equal or both are null |
| 1309 | */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 1310 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1311 | private static boolean equalsHandlesNulls (Object a, Object b) { |
| 1312 | return (a == null) ? (b == null) : a.equals (b); |
| 1313 | } |
| 1314 | |
| 1315 | /** |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 1316 | * Set ServiceState based on intent notifier map. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1317 | * |
| 1318 | * @param m intent notifier map |
| 1319 | * @hide |
| 1320 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1321 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1322 | private void setFromNotifierBundle(Bundle m) { |
Amit Mahajan | bb61b17 | 2020-01-23 18:00:08 -0800 | [diff] [blame] | 1323 | ServiceState ssFromBundle = m.getParcelable(EXTRA_SERVICE_STATE); |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1324 | if (ssFromBundle != null) { |
| 1325 | copyFrom(ssFromBundle); |
| 1326 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1327 | } |
| 1328 | |
| 1329 | /** |
Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 1330 | * Set intent notifier Bundle based on service state. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1331 | * |
Malcolm Chen | 8a8b120 | 2019-12-27 16:49:44 -0800 | [diff] [blame] | 1332 | * Put ServiceState object and its fields into bundle which is used by TelephonyRegistry |
| 1333 | * to broadcast {@link Intent#ACTION_SERVICE_STATE}. |
| 1334 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1335 | * @param m intent notifier Bundle |
| 1336 | * @hide |
Malcolm Chen | 8a8b120 | 2019-12-27 16:49:44 -0800 | [diff] [blame] | 1337 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1338 | */ |
Malcolm Chen | 9993fd6 | 2020-04-28 16:14:01 -0700 | [diff] [blame] | 1339 | @UnsupportedAppUsage |
Malcolm Chen | 8a8b120 | 2019-12-27 16:49:44 -0800 | [diff] [blame] | 1340 | public void fillInNotifierBundle(@NonNull Bundle m) { |
Amit Mahajan | bb61b17 | 2020-01-23 18:00:08 -0800 | [diff] [blame] | 1341 | m.putParcelable(EXTRA_SERVICE_STATE, this); |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1342 | // serviceState already consists of below entries. |
| 1343 | // for backward compatibility, we continue fill in below entries. |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1344 | m.putInt("voiceRegState", mVoiceRegState); |
| 1345 | m.putInt("dataRegState", mDataRegState); |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1346 | m.putInt("dataRoamingType", getDataRoamingType()); |
| 1347 | m.putInt("voiceRoamingType", getVoiceRoamingType()); |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 1348 | m.putString("operator-alpha-long", mOperatorAlphaLong); |
| 1349 | m.putString("operator-alpha-short", mOperatorAlphaShort); |
| 1350 | m.putString("operator-numeric", mOperatorNumeric); |
| 1351 | m.putString("data-operator-alpha-long", mOperatorAlphaLong); |
| 1352 | m.putString("data-operator-alpha-short", mOperatorAlphaShort); |
| 1353 | m.putString("data-operator-numeric", mOperatorNumeric); |
Tobias Thierer | b0800dc | 2016-04-21 17:51:41 +0100 | [diff] [blame] | 1354 | m.putBoolean("manual", mIsManualNetworkSelection); |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1355 | m.putInt("radioTechnology", getRilVoiceRadioTechnology()); |
| 1356 | m.putInt("dataRadioTechnology", getRadioTechnology()); |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1357 | m.putBoolean("cssIndicator", mCssIndicator); |
| 1358 | m.putInt("networkId", mNetworkId); |
| 1359 | m.putInt("systemId", mSystemId); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1360 | m.putInt("cdmaRoamingIndicator", mCdmaRoamingIndicator); |
| 1361 | m.putInt("cdmaDefaultRoamingIndicator", mCdmaDefaultRoamingIndicator); |
Tobias Thierer | b0800dc | 2016-04-21 17:51:41 +0100 | [diff] [blame] | 1362 | m.putBoolean("emergencyOnly", mIsEmergencyOnly); |
chen xu | 0281169 | 2018-10-03 19:07:09 -0700 | [diff] [blame] | 1363 | m.putBoolean("isDataRoamingFromRegistration", getDataRoamingFromRegistration()); |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1364 | m.putBoolean("isUsingCarrierAggregation", isUsingCarrierAggregation()); |
Sooraj Sasindran | c5659ca | 2017-03-08 23:43:17 -0800 | [diff] [blame] | 1365 | m.putInt("LteEarfcnRsrpBoost", mLteEarfcnRsrpBoost); |
Eric Schwarzenbach | 09a7773 | 2018-01-18 14:42:00 -0800 | [diff] [blame] | 1366 | m.putInt("ChannelNumber", mChannelNumber); |
| 1367 | m.putIntArray("CellBandwidths", mCellBandwidths); |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 1368 | m.putInt("mNrFrequencyRange", mNrFrequencyRange); |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 1369 | m.putString("operator-alpha-long-raw", mOperatorAlphaLongRaw); |
| 1370 | m.putString("operator-alpha-short-raw", mOperatorAlphaShortRaw); |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1371 | } |
| 1372 | |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1373 | /** @hide */ |
Malcolm Chen | a1d5e9f | 2018-04-03 17:43:30 -0700 | [diff] [blame] | 1374 | @TestApi |
chen xu | f513b52 | 2018-10-18 16:52:40 -0700 | [diff] [blame] | 1375 | public void setRilVoiceRadioTechnology(@RilRadioTechnology int rt) { |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1376 | Rlog.e(LOG_TAG, "ServiceState.setRilVoiceRadioTechnology() called. It's encouraged to " |
| 1377 | + "use addNetworkRegistrationInfo() instead *******"); |
| 1378 | // Sync to network registration state |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1379 | NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo( |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1380 | NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1381 | if (regInfo == null) { |
| 1382 | regInfo = new NetworkRegistrationInfo.Builder() |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 1383 | .setDomain(NetworkRegistrationInfo.DOMAIN_CS) |
| 1384 | .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) |
| 1385 | .build(); |
chen xu | f513b52 | 2018-10-18 16:52:40 -0700 | [diff] [blame] | 1386 | } |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1387 | regInfo.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt)); |
| 1388 | addNetworkRegistrationInfo(regInfo); |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1389 | } |
| 1390 | |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1391 | |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1392 | /** @hide */ |
Malcolm Chen | a1d5e9f | 2018-04-03 17:43:30 -0700 | [diff] [blame] | 1393 | @TestApi |
chen xu | f513b52 | 2018-10-18 16:52:40 -0700 | [diff] [blame] | 1394 | public void setRilDataRadioTechnology(@RilRadioTechnology int rt) { |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1395 | Rlog.e(LOG_TAG, "ServiceState.setRilDataRadioTechnology() called. It's encouraged to " |
| 1396 | + "use addNetworkRegistrationInfo() instead *******"); |
| 1397 | // Sync to network registration state. Always write down the WWAN transport. For AP-assisted |
| 1398 | // mode device, use addNetworkRegistrationInfo() to set the correct transport if RAT |
| 1399 | // is IWLAN. |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1400 | NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo( |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1401 | NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
chen xu | f513b52 | 2018-10-18 16:52:40 -0700 | [diff] [blame] | 1402 | |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1403 | if (regInfo == null) { |
| 1404 | regInfo = new NetworkRegistrationInfo.Builder() |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 1405 | .setDomain(NetworkRegistrationInfo.DOMAIN_PS) |
| 1406 | .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) |
| 1407 | .build(); |
chen xu | f513b52 | 2018-10-18 16:52:40 -0700 | [diff] [blame] | 1408 | } |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1409 | regInfo.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt)); |
| 1410 | addNetworkRegistrationInfo(regInfo); |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1411 | } |
| 1412 | |
| 1413 | /** @hide */ |
Robert Greenwalt | ea0d7139 | 2016-07-28 18:50:10 -0700 | [diff] [blame] | 1414 | public boolean isUsingCarrierAggregation() { |
Rambo Wang | 8a41bbf | 2020-05-08 14:50:21 -0700 | [diff] [blame] | 1415 | boolean isUsingCa = false; |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1416 | NetworkRegistrationInfo nri = getNetworkRegistrationInfo( |
| 1417 | NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
| 1418 | if (nri != null) { |
| 1419 | DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo(); |
| 1420 | if (dsri != null) { |
Rambo Wang | 8a41bbf | 2020-05-08 14:50:21 -0700 | [diff] [blame] | 1421 | isUsingCa = dsri.isUsingCarrierAggregation(); |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1422 | } |
| 1423 | } |
Rambo Wang | 8a41bbf | 2020-05-08 14:50:21 -0700 | [diff] [blame] | 1424 | return isUsingCa || getCellBandwidths().length > 1; |
Robert Greenwalt | ea0d7139 | 2016-07-28 18:50:10 -0700 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | /** @hide */ |
| 1428 | public void setIsUsingCarrierAggregation(boolean ca) { |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1429 | NetworkRegistrationInfo nri = getNetworkRegistrationInfo( |
| 1430 | NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
| 1431 | if (nri != null) { |
| 1432 | DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo(); |
| 1433 | if (dsri != null) { |
| 1434 | dsri.setIsUsingCarrierAggregation(ca); |
Qiong Liu | c43aef7 | 2019-08-26 18:58:07 +0800 | [diff] [blame] | 1435 | addNetworkRegistrationInfo(nri); |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1436 | } |
| 1437 | } |
Robert Greenwalt | ea0d7139 | 2016-07-28 18:50:10 -0700 | [diff] [blame] | 1438 | } |
| 1439 | |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 1440 | /** |
Jayachandran C | 4d62c63 | 2019-11-07 00:47:28 -0800 | [diff] [blame] | 1441 | * Get the 5G NR frequency range the device is currently registered. |
| 1442 | * |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 1443 | * @return the frequency range of 5G NR. |
| 1444 | * @hide |
| 1445 | */ |
| 1446 | public @FrequencyRange int getNrFrequencyRange() { |
| 1447 | return mNrFrequencyRange; |
| 1448 | } |
| 1449 | |
| 1450 | /** |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 1451 | * Get the NR 5G state of the mobile data network. |
| 1452 | * @return the NR 5G state. |
Pengquan Meng | 123cd32 | 2018-12-06 17:48:05 -0800 | [diff] [blame] | 1453 | * @hide |
| 1454 | */ |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 1455 | public @NRState int getNrState() { |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1456 | final NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo( |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1457 | NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1458 | if (regInfo == null) return NetworkRegistrationInfo.NR_STATE_NONE; |
| 1459 | return regInfo.getNrState(); |
Pengquan Meng | 123cd32 | 2018-12-06 17:48:05 -0800 | [diff] [blame] | 1460 | } |
| 1461 | |
| 1462 | /** |
Pengquan Meng | 6aa5213 | 2018-11-13 17:06:34 -0800 | [diff] [blame] | 1463 | * @param nrFrequencyRange the frequency range of 5G NR. |
| 1464 | * @hide |
| 1465 | */ |
| 1466 | public void setNrFrequencyRange(@FrequencyRange int nrFrequencyRange) { |
| 1467 | mNrFrequencyRange = nrFrequencyRange; |
| 1468 | } |
| 1469 | |
Robert Greenwalt | ea0d7139 | 2016-07-28 18:50:10 -0700 | [diff] [blame] | 1470 | /** @hide */ |
Sooraj Sasindran | c5659ca | 2017-03-08 23:43:17 -0800 | [diff] [blame] | 1471 | public int getLteEarfcnRsrpBoost() { |
| 1472 | return mLteEarfcnRsrpBoost; |
| 1473 | } |
| 1474 | |
| 1475 | /** @hide */ |
| 1476 | public void setLteEarfcnRsrpBoost(int LteEarfcnRsrpBoost) { |
| 1477 | mLteEarfcnRsrpBoost = LteEarfcnRsrpBoost; |
| 1478 | } |
| 1479 | |
| 1480 | /** @hide */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 1481 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1482 | public void setCssIndicator(int css) { |
| 1483 | this.mCssIndicator = (css != 0); |
| 1484 | } |
| 1485 | |
| 1486 | /** @hide */ |
Jack Yu | 1b8b389 | 2018-02-22 17:37:38 -0800 | [diff] [blame] | 1487 | @TestApi |
Jack Yu | 2661fac | 2018-03-15 13:51:05 -0700 | [diff] [blame] | 1488 | public void setCdmaSystemAndNetworkId(int systemId, int networkId) { |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1489 | this.mSystemId = systemId; |
| 1490 | this.mNetworkId = networkId; |
| 1491 | } |
| 1492 | |
| 1493 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1494 | @UnsupportedAppUsage |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1495 | public int getRilVoiceRadioTechnology() { |
Jack Yu | 5ff5ab5 | 2019-04-02 13:14:03 -0700 | [diff] [blame] | 1496 | NetworkRegistrationInfo wwanRegInfo = getNetworkRegistrationInfo( |
| 1497 | NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
| 1498 | if (wwanRegInfo != null) { |
| 1499 | return networkTypeToRilRadioTechnology(wwanRegInfo.getAccessNetworkTechnology()); |
| 1500 | } |
| 1501 | return RIL_RADIO_TECHNOLOGY_UNKNOWN; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1502 | } |
Mathias Agopian | d13f9aa | 2012-02-24 19:28:42 -0800 | [diff] [blame] | 1503 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1504 | @UnsupportedAppUsage |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1505 | public int getRilDataRadioTechnology() { |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 1506 | return networkTypeToRilRadioTechnology(getDataNetworkType()); |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1507 | } |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 1508 | |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1509 | /** |
| 1510 | * @hide |
| 1511 | * @Deprecated to be removed Q3 2013 use {@link #getRilDataRadioTechnology} or |
| 1512 | * {@link #getRilVoiceRadioTechnology} |
| 1513 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1514 | @UnsupportedAppUsage |
Mathias Agopian | d13f9aa | 2012-02-24 19:28:42 -0800 | [diff] [blame] | 1515 | public int getRadioTechnology() { |
Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 1516 | Rlog.e(LOG_TAG, "ServiceState.getRadioTechnology() DEPRECATED will be removed *******"); |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1517 | return getRilDataRadioTechnology(); |
Mathias Agopian | d13f9aa | 2012-02-24 19:28:42 -0800 | [diff] [blame] | 1518 | } |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1519 | |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 1520 | /** |
| 1521 | * Transform RIL radio technology {@link RilRadioTechnology} value to Network |
| 1522 | * type {@link NetworkType}. |
| 1523 | * |
| 1524 | * @param rat The RIL radio technology {@link RilRadioTechnology}. |
| 1525 | * @return The network type {@link NetworkType}. |
| 1526 | * |
| 1527 | * @hide |
| 1528 | */ |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1529 | public static int rilRadioTechnologyToNetworkType(@RilRadioTechnology int rat) { |
| 1530 | switch(rat) { |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1531 | case RIL_RADIO_TECHNOLOGY_GPRS: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1532 | return TelephonyManager.NETWORK_TYPE_GPRS; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1533 | case RIL_RADIO_TECHNOLOGY_EDGE: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1534 | return TelephonyManager.NETWORK_TYPE_EDGE; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1535 | case RIL_RADIO_TECHNOLOGY_UMTS: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1536 | return TelephonyManager.NETWORK_TYPE_UMTS; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1537 | case RIL_RADIO_TECHNOLOGY_HSDPA: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1538 | return TelephonyManager.NETWORK_TYPE_HSDPA; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1539 | case RIL_RADIO_TECHNOLOGY_HSUPA: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1540 | return TelephonyManager.NETWORK_TYPE_HSUPA; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1541 | case RIL_RADIO_TECHNOLOGY_HSPA: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1542 | return TelephonyManager.NETWORK_TYPE_HSPA; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1543 | case RIL_RADIO_TECHNOLOGY_IS95A: |
| 1544 | case RIL_RADIO_TECHNOLOGY_IS95B: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1545 | return TelephonyManager.NETWORK_TYPE_CDMA; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1546 | case RIL_RADIO_TECHNOLOGY_1xRTT: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1547 | return TelephonyManager.NETWORK_TYPE_1xRTT; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1548 | case RIL_RADIO_TECHNOLOGY_EVDO_0: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1549 | return TelephonyManager.NETWORK_TYPE_EVDO_0; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1550 | case RIL_RADIO_TECHNOLOGY_EVDO_A: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1551 | return TelephonyManager.NETWORK_TYPE_EVDO_A; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1552 | case RIL_RADIO_TECHNOLOGY_EVDO_B: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1553 | return TelephonyManager.NETWORK_TYPE_EVDO_B; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1554 | case RIL_RADIO_TECHNOLOGY_EHRPD: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1555 | return TelephonyManager.NETWORK_TYPE_EHRPD; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1556 | case RIL_RADIO_TECHNOLOGY_LTE: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1557 | return TelephonyManager.NETWORK_TYPE_LTE; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1558 | case RIL_RADIO_TECHNOLOGY_HSPAP: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1559 | return TelephonyManager.NETWORK_TYPE_HSPAP; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1560 | case RIL_RADIO_TECHNOLOGY_GSM: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1561 | return TelephonyManager.NETWORK_TYPE_GSM; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1562 | case RIL_RADIO_TECHNOLOGY_TD_SCDMA: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1563 | return TelephonyManager.NETWORK_TYPE_TD_SCDMA; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1564 | case RIL_RADIO_TECHNOLOGY_IWLAN: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1565 | return TelephonyManager.NETWORK_TYPE_IWLAN; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1566 | case RIL_RADIO_TECHNOLOGY_LTE_CA: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1567 | return TelephonyManager.NETWORK_TYPE_LTE_CA; |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1568 | case RIL_RADIO_TECHNOLOGY_NR: |
Pengquan Meng | 82e6b2a | 2018-12-07 14:41:18 -0800 | [diff] [blame] | 1569 | return TelephonyManager.NETWORK_TYPE_NR; |
| 1570 | default: |
| 1571 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 1572 | } |
| 1573 | } |
| 1574 | |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1575 | /** @hide */ |
Jack Yu | 677cfaa2 | 2018-01-31 00:33:20 -0800 | [diff] [blame] | 1576 | public static int rilRadioTechnologyToAccessNetworkType(@RilRadioTechnology int rt) { |
| 1577 | switch(rt) { |
| 1578 | case RIL_RADIO_TECHNOLOGY_GPRS: |
| 1579 | case RIL_RADIO_TECHNOLOGY_EDGE: |
| 1580 | case RIL_RADIO_TECHNOLOGY_GSM: |
| 1581 | return AccessNetworkType.GERAN; |
| 1582 | case RIL_RADIO_TECHNOLOGY_UMTS: |
| 1583 | case RIL_RADIO_TECHNOLOGY_HSDPA: |
| 1584 | case RIL_RADIO_TECHNOLOGY_HSPAP: |
| 1585 | case RIL_RADIO_TECHNOLOGY_HSUPA: |
| 1586 | case RIL_RADIO_TECHNOLOGY_HSPA: |
| 1587 | case RIL_RADIO_TECHNOLOGY_TD_SCDMA: |
| 1588 | return AccessNetworkType.UTRAN; |
| 1589 | case RIL_RADIO_TECHNOLOGY_IS95A: |
| 1590 | case RIL_RADIO_TECHNOLOGY_IS95B: |
| 1591 | case RIL_RADIO_TECHNOLOGY_1xRTT: |
| 1592 | case RIL_RADIO_TECHNOLOGY_EVDO_0: |
| 1593 | case RIL_RADIO_TECHNOLOGY_EVDO_A: |
| 1594 | case RIL_RADIO_TECHNOLOGY_EVDO_B: |
| 1595 | case RIL_RADIO_TECHNOLOGY_EHRPD: |
| 1596 | return AccessNetworkType.CDMA2000; |
| 1597 | case RIL_RADIO_TECHNOLOGY_LTE: |
| 1598 | case RIL_RADIO_TECHNOLOGY_LTE_CA: |
| 1599 | return AccessNetworkType.EUTRAN; |
Sarah Chin | d1941e57 | 2019-12-13 11:12:28 -0800 | [diff] [blame] | 1600 | case RIL_RADIO_TECHNOLOGY_NR: |
| 1601 | return AccessNetworkType.NGRAN; |
Jack Yu | 677cfaa2 | 2018-01-31 00:33:20 -0800 | [diff] [blame] | 1602 | case RIL_RADIO_TECHNOLOGY_IWLAN: |
| 1603 | return AccessNetworkType.IWLAN; |
| 1604 | case RIL_RADIO_TECHNOLOGY_UNKNOWN: |
| 1605 | default: |
| 1606 | return AccessNetworkType.UNKNOWN; |
| 1607 | } |
| 1608 | } |
| 1609 | |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 1610 | /** |
| 1611 | * Transform network type {@link NetworkType} value to RIL radio technology |
| 1612 | * {@link RilRadioTechnology}. |
| 1613 | * |
| 1614 | * @param networkType The network type {@link NetworkType}. |
| 1615 | * @return The RIL radio technology {@link RilRadioTechnology}. |
| 1616 | * |
| 1617 | * @hide |
| 1618 | */ |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1619 | public static int networkTypeToRilRadioTechnology(int networkType) { |
| 1620 | switch(networkType) { |
| 1621 | case TelephonyManager.NETWORK_TYPE_GPRS: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1622 | return RIL_RADIO_TECHNOLOGY_GPRS; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1623 | case TelephonyManager.NETWORK_TYPE_EDGE: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1624 | return RIL_RADIO_TECHNOLOGY_EDGE; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1625 | case TelephonyManager.NETWORK_TYPE_UMTS: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1626 | return RIL_RADIO_TECHNOLOGY_UMTS; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1627 | case TelephonyManager.NETWORK_TYPE_HSDPA: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1628 | return RIL_RADIO_TECHNOLOGY_HSDPA; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1629 | case TelephonyManager.NETWORK_TYPE_HSUPA: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1630 | return RIL_RADIO_TECHNOLOGY_HSUPA; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1631 | case TelephonyManager.NETWORK_TYPE_HSPA: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1632 | return RIL_RADIO_TECHNOLOGY_HSPA; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1633 | case TelephonyManager.NETWORK_TYPE_CDMA: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1634 | return RIL_RADIO_TECHNOLOGY_IS95A; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1635 | case TelephonyManager.NETWORK_TYPE_1xRTT: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1636 | return RIL_RADIO_TECHNOLOGY_1xRTT; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1637 | case TelephonyManager.NETWORK_TYPE_EVDO_0: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1638 | return RIL_RADIO_TECHNOLOGY_EVDO_0; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1639 | case TelephonyManager.NETWORK_TYPE_EVDO_A: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1640 | return RIL_RADIO_TECHNOLOGY_EVDO_A; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1641 | case TelephonyManager.NETWORK_TYPE_EVDO_B: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1642 | return RIL_RADIO_TECHNOLOGY_EVDO_B; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1643 | case TelephonyManager.NETWORK_TYPE_EHRPD: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1644 | return RIL_RADIO_TECHNOLOGY_EHRPD; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1645 | case TelephonyManager.NETWORK_TYPE_LTE: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1646 | return RIL_RADIO_TECHNOLOGY_LTE; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1647 | case TelephonyManager.NETWORK_TYPE_HSPAP: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1648 | return RIL_RADIO_TECHNOLOGY_HSPAP; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1649 | case TelephonyManager.NETWORK_TYPE_GSM: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1650 | return RIL_RADIO_TECHNOLOGY_GSM; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1651 | case TelephonyManager.NETWORK_TYPE_TD_SCDMA: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1652 | return RIL_RADIO_TECHNOLOGY_TD_SCDMA; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1653 | case TelephonyManager.NETWORK_TYPE_IWLAN: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1654 | return RIL_RADIO_TECHNOLOGY_IWLAN; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1655 | case TelephonyManager.NETWORK_TYPE_LTE_CA: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1656 | return RIL_RADIO_TECHNOLOGY_LTE_CA; |
Avinash Nalluri | 61b44a2 | 2019-06-19 19:13:28 -0700 | [diff] [blame] | 1657 | case TelephonyManager.NETWORK_TYPE_NR: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1658 | return RIL_RADIO_TECHNOLOGY_NR; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1659 | default: |
Taesu Lee | e376b8c | 2019-11-14 14:41:40 +0900 | [diff] [blame] | 1660 | return RIL_RADIO_TECHNOLOGY_UNKNOWN; |
Malcolm Chen | 0a01c6b | 2018-01-29 17:09:21 -0800 | [diff] [blame] | 1661 | } |
| 1662 | } |
| 1663 | |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 1664 | /** |
| 1665 | * Get current data network type. |
| 1666 | * |
| 1667 | * Note that for IWLAN AP-assisted mode device, which is reporting both camped access networks |
| 1668 | * (cellular RAT and IWLAN)at the same time, this API is simulating the old legacy mode device |
| 1669 | * behavior, |
| 1670 | * |
| 1671 | * @return Current data network type |
| 1672 | * @hide |
| 1673 | */ |
Hall Liu | 5884933 | 2019-12-27 19:42:20 -0800 | [diff] [blame] | 1674 | @TestApi |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 1675 | public @NetworkType int getDataNetworkType() { |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 1676 | final NetworkRegistrationInfo iwlanRegInfo = getNetworkRegistrationInfo( |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1677 | NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 1678 | final NetworkRegistrationInfo wwanRegInfo = getNetworkRegistrationInfo( |
| 1679 | NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
| 1680 | |
| 1681 | // For legacy mode device, or AP-assisted mode device but IWLAN is out of service, use |
| 1682 | // the RAT from cellular. |
| 1683 | if (iwlanRegInfo == null || !iwlanRegInfo.isInService()) { |
| 1684 | return (wwanRegInfo != null) ? wwanRegInfo.getAccessNetworkTechnology() |
| 1685 | : TelephonyManager.NETWORK_TYPE_UNKNOWN; |
Jack Yu | 2bd0320 | 2019-02-20 15:48:07 -0800 | [diff] [blame] | 1686 | } |
| 1687 | |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 1688 | // At this point, it must be an AP-assisted mode device and IWLAN is in service. We should |
| 1689 | // use the RAT from IWLAN service is cellular is out of service, or when both are in service |
| 1690 | // and any APN type of data is preferred on IWLAN. |
| 1691 | if (!wwanRegInfo.isInService() || mIsIwlanPreferred) { |
| 1692 | return iwlanRegInfo.getAccessNetworkTechnology(); |
chen xu | f513b52 | 2018-10-18 16:52:40 -0700 | [diff] [blame] | 1693 | } |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 1694 | |
| 1695 | // If both cellular and IWLAN are in service, but no APN is preferred on IWLAN, still use |
| 1696 | // the RAT from cellular. |
| 1697 | return wwanRegInfo.getAccessNetworkTechnology(); |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1698 | } |
| 1699 | |
| 1700 | /** @hide */ |
chen xu | f513b52 | 2018-10-18 16:52:40 -0700 | [diff] [blame] | 1701 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 1702 | public @NetworkType int getVoiceNetworkType() { |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1703 | final NetworkRegistrationInfo regState = getNetworkRegistrationInfo( |
| 1704 | NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
chen xu | f513b52 | 2018-10-18 16:52:40 -0700 | [diff] [blame] | 1705 | if (regState != null) { |
| 1706 | return regState.getAccessNetworkTechnology(); |
| 1707 | } |
| 1708 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 1709 | } |
| 1710 | |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 1711 | /** @hide */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 1712 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1713 | public int getCssIndicator() { |
| 1714 | return this.mCssIndicator ? 1 : 0; |
| 1715 | } |
| 1716 | |
Jack Yu | 9cd3b7b | 2018-01-02 15:51:34 -0800 | [diff] [blame] | 1717 | /** |
| 1718 | * Get the CDMA NID (Network Identification Number), a number uniquely identifying a network |
| 1719 | * within a wireless system. (Defined in 3GPP2 C.S0023 3.4.8) |
| 1720 | * @return The CDMA NID or {@link #UNKNOWN_ID} if not available. |
| 1721 | */ |
Jack Yu | 2661fac | 2018-03-15 13:51:05 -0700 | [diff] [blame] | 1722 | public int getCdmaNetworkId() { |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1723 | return this.mNetworkId; |
| 1724 | } |
| 1725 | |
Jack Yu | 9cd3b7b | 2018-01-02 15:51:34 -0800 | [diff] [blame] | 1726 | /** |
| 1727 | * Get the CDMA SID (System Identification Number), a number uniquely identifying a wireless |
| 1728 | * system. (Defined in 3GPP2 C.S0023 3.4.8) |
| 1729 | * @return The CDMA SID or {@link #UNKNOWN_ID} if not available. |
| 1730 | */ |
Jack Yu | 2661fac | 2018-03-15 13:51:05 -0700 | [diff] [blame] | 1731 | public int getCdmaSystemId() { |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1732 | return this.mSystemId; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1733 | } |
Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 1734 | |
| 1735 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1736 | @UnsupportedAppUsage |
Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 1737 | public static boolean isGsm(int radioTechnology) { |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 1738 | return radioTechnology == RIL_RADIO_TECHNOLOGY_GPRS |
| 1739 | || radioTechnology == RIL_RADIO_TECHNOLOGY_EDGE |
| 1740 | || radioTechnology == RIL_RADIO_TECHNOLOGY_UMTS |
| 1741 | || radioTechnology == RIL_RADIO_TECHNOLOGY_HSDPA |
| 1742 | || radioTechnology == RIL_RADIO_TECHNOLOGY_HSUPA |
| 1743 | || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPA |
| 1744 | || radioTechnology == RIL_RADIO_TECHNOLOGY_LTE |
| 1745 | || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPAP |
Etan Cohen | 5e5bc4b | 2014-10-08 17:10:33 -0700 | [diff] [blame] | 1746 | || radioTechnology == RIL_RADIO_TECHNOLOGY_GSM |
Yashdev Singh | bece926 | 2015-02-23 13:04:51 -0800 | [diff] [blame] | 1747 | || radioTechnology == RIL_RADIO_TECHNOLOGY_TD_SCDMA |
Ajay Nambi | 7965fa4 | 2015-05-14 18:48:33 -0700 | [diff] [blame] | 1748 | || radioTechnology == RIL_RADIO_TECHNOLOGY_IWLAN |
Sukanya Rajkhowa | ab815c1 | 2019-03-25 16:51:26 -0700 | [diff] [blame] | 1749 | || radioTechnology == RIL_RADIO_TECHNOLOGY_LTE_CA |
| 1750 | || radioTechnology == RIL_RADIO_TECHNOLOGY_NR; |
Ajay Nambi | 7965fa4 | 2015-05-14 18:48:33 -0700 | [diff] [blame] | 1751 | |
Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 1752 | } |
| 1753 | |
| 1754 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1755 | @UnsupportedAppUsage |
Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 1756 | public static boolean isCdma(int radioTechnology) { |
Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 1757 | return radioTechnology == RIL_RADIO_TECHNOLOGY_IS95A |
| 1758 | || radioTechnology == RIL_RADIO_TECHNOLOGY_IS95B |
| 1759 | || radioTechnology == RIL_RADIO_TECHNOLOGY_1xRTT |
| 1760 | || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_0 |
| 1761 | || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_A |
| 1762 | || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_B |
Etan Cohen | 5e5bc4b | 2014-10-08 17:10:33 -0700 | [diff] [blame] | 1763 | || radioTechnology == RIL_RADIO_TECHNOLOGY_EHRPD; |
Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 1764 | } |
Etan Cohen | dcc0736 | 2014-09-23 16:03:44 -0700 | [diff] [blame] | 1765 | |
Amit Mahajan | 13a98b6 | 2015-02-26 10:46:17 -0800 | [diff] [blame] | 1766 | /** @hide */ |
Sarah Chin | 96169ca | 2020-01-07 17:45:05 -0800 | [diff] [blame] | 1767 | public static boolean isPsOnlyTech(int radioTechnology) { |
| 1768 | return radioTechnology == RIL_RADIO_TECHNOLOGY_LTE |
| 1769 | || radioTechnology == RIL_RADIO_TECHNOLOGY_LTE_CA |
| 1770 | || radioTechnology == RIL_RADIO_TECHNOLOGY_NR; |
Ajay Nambi | 7965fa4 | 2015-05-14 18:48:33 -0700 | [diff] [blame] | 1771 | } |
| 1772 | |
| 1773 | /** @hide */ |
Sukanya Rajkhowa | ab815c1 | 2019-03-25 16:51:26 -0700 | [diff] [blame] | 1774 | public static boolean isPsTech(int radioTechnology) { |
| 1775 | return radioTechnology == RIL_RADIO_TECHNOLOGY_LTE || |
| 1776 | radioTechnology == RIL_RADIO_TECHNOLOGY_LTE_CA || |
| 1777 | radioTechnology == RIL_RADIO_TECHNOLOGY_NR; |
| 1778 | } |
| 1779 | |
| 1780 | /** @hide */ |
Mathew Inwood | 55418ea | 2018-12-20 15:30:45 +0000 | [diff] [blame] | 1781 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Jack Yu | 7d675e5 | 2018-12-17 16:09:03 -0800 | [diff] [blame] | 1782 | public static boolean bearerBitmapHasCdma(int networkTypeBitmask) { |
| 1783 | return (RIL_RADIO_CDMA_TECHNOLOGY_BITMASK |
| 1784 | & convertNetworkTypeBitmaskToBearerBitmask(networkTypeBitmask)) != 0; |
Amit Mahajan | 13a98b6 | 2015-02-26 10:46:17 -0800 | [diff] [blame] | 1785 | } |
| 1786 | |
| 1787 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1788 | @UnsupportedAppUsage |
Amit Mahajan | 13a98b6 | 2015-02-26 10:46:17 -0800 | [diff] [blame] | 1789 | public static boolean bitmaskHasTech(int bearerBitmask, int radioTech) { |
| 1790 | if (bearerBitmask == 0) { |
| 1791 | return true; |
| 1792 | } else if (radioTech >= 1) { |
| 1793 | return ((bearerBitmask & (1 << (radioTech - 1))) != 0); |
| 1794 | } |
| 1795 | return false; |
| 1796 | } |
| 1797 | |
| 1798 | /** @hide */ |
| 1799 | public static int getBitmaskForTech(int radioTech) { |
| 1800 | if (radioTech >= 1) { |
| 1801 | return (1 << (radioTech - 1)); |
| 1802 | } |
| 1803 | return 0; |
| 1804 | } |
| 1805 | |
| 1806 | /** @hide */ |
| 1807 | public static int getBitmaskFromString(String bearerList) { |
| 1808 | String[] bearers = bearerList.split("\\|"); |
| 1809 | int bearerBitmask = 0; |
| 1810 | for (String bearer : bearers) { |
| 1811 | int bearerInt = 0; |
| 1812 | try { |
| 1813 | bearerInt = Integer.parseInt(bearer.trim()); |
| 1814 | } catch (NumberFormatException nfe) { |
| 1815 | return 0; |
| 1816 | } |
| 1817 | |
| 1818 | if (bearerInt == 0) { |
| 1819 | return 0; |
| 1820 | } |
| 1821 | |
| 1822 | bearerBitmask |= getBitmaskForTech(bearerInt); |
| 1823 | } |
| 1824 | return bearerBitmask; |
| 1825 | } |
| 1826 | |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 1827 | /** |
| 1828 | * Convert network type bitmask to bearer bitmask. |
| 1829 | * |
| 1830 | * @param networkTypeBitmask The network type bitmask value |
| 1831 | * @return The bearer bitmask value. |
| 1832 | * |
| 1833 | * @hide |
| 1834 | */ |
Cassie | d53df96 | 2017-12-05 13:34:33 -0800 | [diff] [blame] | 1835 | public static int convertNetworkTypeBitmaskToBearerBitmask(int networkTypeBitmask) { |
| 1836 | if (networkTypeBitmask == 0) { |
| 1837 | return 0; |
| 1838 | } |
| 1839 | int bearerBitmask = 0; |
| 1840 | for (int bearerInt = 0; bearerInt < NEXT_RIL_RADIO_TECHNOLOGY; bearerInt++) { |
| 1841 | if (bitmaskHasTech(networkTypeBitmask, rilRadioTechnologyToNetworkType(bearerInt))) { |
| 1842 | bearerBitmask |= getBitmaskForTech(bearerInt); |
| 1843 | } |
| 1844 | } |
| 1845 | return bearerBitmask; |
| 1846 | } |
| 1847 | |
SongFerngWang | e5202be | 2019-12-02 21:19:24 +0800 | [diff] [blame] | 1848 | /** |
| 1849 | * Convert bearer bitmask to network type bitmask. |
| 1850 | * |
| 1851 | * @param bearerBitmask The bearer bitmask value. |
| 1852 | * @return The network type bitmask value. |
| 1853 | * |
| 1854 | * @hide |
| 1855 | */ |
Cassie | d53df96 | 2017-12-05 13:34:33 -0800 | [diff] [blame] | 1856 | public static int convertBearerBitmaskToNetworkTypeBitmask(int bearerBitmask) { |
| 1857 | if (bearerBitmask == 0) { |
| 1858 | return 0; |
| 1859 | } |
| 1860 | int networkTypeBitmask = 0; |
| 1861 | for (int bearerInt = 0; bearerInt < NEXT_RIL_RADIO_TECHNOLOGY; bearerInt++) { |
| 1862 | if (bitmaskHasTech(bearerBitmask, bearerInt)) { |
| 1863 | networkTypeBitmask |= getBitmaskForTech(rilRadioTechnologyToNetworkType(bearerInt)); |
| 1864 | } |
| 1865 | } |
| 1866 | return networkTypeBitmask; |
| 1867 | } |
| 1868 | |
Etan Cohen | dcc0736 | 2014-09-23 16:03:44 -0700 | [diff] [blame] | 1869 | /** |
| 1870 | * Returns a merged ServiceState consisting of the base SS with voice settings from the |
| 1871 | * voice SS. The voice SS is only used if it is IN_SERVICE (otherwise the base SS is returned). |
| 1872 | * @hide |
| 1873 | * */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 1874 | @UnsupportedAppUsage |
Etan Cohen | dcc0736 | 2014-09-23 16:03:44 -0700 | [diff] [blame] | 1875 | public static ServiceState mergeServiceStates(ServiceState baseSs, ServiceState voiceSs) { |
| 1876 | if (voiceSs.mVoiceRegState != STATE_IN_SERVICE) { |
| 1877 | return baseSs; |
| 1878 | } |
| 1879 | |
| 1880 | ServiceState newSs = new ServiceState(baseSs); |
| 1881 | |
| 1882 | // voice overrides |
| 1883 | newSs.mVoiceRegState = voiceSs.mVoiceRegState; |
| 1884 | newSs.mIsEmergencyOnly = false; // only get here if voice is IN_SERVICE |
| 1885 | |
| 1886 | return newSs; |
| 1887 | } |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1888 | |
| 1889 | /** |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1890 | * Get all of the available network registration info. |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1891 | * |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1892 | * @return List of {@link NetworkRegistrationInfo} |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1893 | */ |
Jack Yu | 8eb6ca8 | 2019-03-01 12:04:50 -0800 | [diff] [blame] | 1894 | @NonNull |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1895 | public List<NetworkRegistrationInfo> getNetworkRegistrationInfoList() { |
| 1896 | synchronized (mNetworkRegistrationInfos) { |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1897 | List<NetworkRegistrationInfo> newList = new ArrayList<>(); |
| 1898 | for (NetworkRegistrationInfo nri : mNetworkRegistrationInfos) { |
| 1899 | newList.add(new NetworkRegistrationInfo(nri)); |
| 1900 | } |
| 1901 | return newList; |
Malcolm Chen | 574b41a | 2018-02-13 15:42:58 -0800 | [diff] [blame] | 1902 | } |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1903 | } |
| 1904 | |
| 1905 | /** |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1906 | * Get the network registration info list for the transport type. |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1907 | * |
Jack Yu | ef25faf | 2019-03-14 15:42:09 -0700 | [diff] [blame] | 1908 | * @param transportType The transport type |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1909 | * @return List of {@link NetworkRegistrationInfo} |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1910 | * @hide |
| 1911 | */ |
Jack Yu | 8eb6ca8 | 2019-03-01 12:04:50 -0800 | [diff] [blame] | 1912 | @NonNull |
Jack Yu | f2add90 | 2018-07-12 15:10:34 -0700 | [diff] [blame] | 1913 | @SystemApi |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1914 | public List<NetworkRegistrationInfo> getNetworkRegistrationInfoListForTransportType( |
Jack Yu | ef25faf | 2019-03-14 15:42:09 -0700 | [diff] [blame] | 1915 | @TransportType int transportType) { |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1916 | List<NetworkRegistrationInfo> list = new ArrayList<>(); |
Malcolm Chen | 574b41a | 2018-02-13 15:42:58 -0800 | [diff] [blame] | 1917 | |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1918 | synchronized (mNetworkRegistrationInfos) { |
| 1919 | for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) { |
| 1920 | if (networkRegistrationInfo.getTransportType() == transportType) { |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1921 | list.add(new NetworkRegistrationInfo(networkRegistrationInfo)); |
Malcolm Chen | 574b41a | 2018-02-13 15:42:58 -0800 | [diff] [blame] | 1922 | } |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1923 | } |
| 1924 | } |
Malcolm Chen | 574b41a | 2018-02-13 15:42:58 -0800 | [diff] [blame] | 1925 | |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1926 | return list; |
| 1927 | } |
| 1928 | |
| 1929 | /** |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1930 | * Get the network registration info list for the network domain. |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1931 | * |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1932 | * @param domain The network {@link NetworkRegistrationInfo.Domain domain} |
| 1933 | * @return List of {@link NetworkRegistrationInfo} |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1934 | * @hide |
| 1935 | */ |
Jack Yu | 8eb6ca8 | 2019-03-01 12:04:50 -0800 | [diff] [blame] | 1936 | @NonNull |
Jack Yu | f2add90 | 2018-07-12 15:10:34 -0700 | [diff] [blame] | 1937 | @SystemApi |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1938 | public List<NetworkRegistrationInfo> getNetworkRegistrationInfoListForDomain( |
Jack Yu | b4ae477 | 2018-10-02 11:14:38 -0700 | [diff] [blame] | 1939 | @Domain int domain) { |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1940 | List<NetworkRegistrationInfo> list = new ArrayList<>(); |
Jack Yu | b4ae477 | 2018-10-02 11:14:38 -0700 | [diff] [blame] | 1941 | |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1942 | synchronized (mNetworkRegistrationInfos) { |
| 1943 | for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) { |
Nathan Harold | c41cb73 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 1944 | if ((networkRegistrationInfo.getDomain() & domain) != 0) { |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1945 | list.add(new NetworkRegistrationInfo(networkRegistrationInfo)); |
Jack Yu | b4ae477 | 2018-10-02 11:14:38 -0700 | [diff] [blame] | 1946 | } |
| 1947 | } |
| 1948 | } |
| 1949 | |
| 1950 | return list; |
| 1951 | } |
| 1952 | |
| 1953 | /** |
Jack Yu | 37a1fc3 | 2018-10-02 17:01:51 -0700 | [diff] [blame] | 1954 | * Get the network registration state for the transport type and network domain. |
Mingming Cai | a42253b | 2020-01-30 17:10:38 -0800 | [diff] [blame] | 1955 | * If multiple domains are in the input bitmask, only the first one from |
| 1956 | * networkRegistrationInfo.getDomain() will be returned. |
Jack Yu | b4ae477 | 2018-10-02 11:14:38 -0700 | [diff] [blame] | 1957 | * |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1958 | * @param domain The network {@link NetworkRegistrationInfo.Domain domain} |
Jack Yu | ef25faf | 2019-03-14 15:42:09 -0700 | [diff] [blame] | 1959 | * @param transportType The transport type |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1960 | * @return The matching {@link NetworkRegistrationInfo} |
Jack Yu | b4ae477 | 2018-10-02 11:14:38 -0700 | [diff] [blame] | 1961 | * @hide |
Jack Yu | b4ae477 | 2018-10-02 11:14:38 -0700 | [diff] [blame] | 1962 | */ |
Jack Yu | 8eb6ca8 | 2019-03-01 12:04:50 -0800 | [diff] [blame] | 1963 | @Nullable |
Jack Yu | b4ae477 | 2018-10-02 11:14:38 -0700 | [diff] [blame] | 1964 | @SystemApi |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1965 | public NetworkRegistrationInfo getNetworkRegistrationInfo(@Domain int domain, |
| 1966 | @TransportType int transportType) { |
| 1967 | synchronized (mNetworkRegistrationInfos) { |
| 1968 | for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) { |
| 1969 | if (networkRegistrationInfo.getTransportType() == transportType |
Nathan Harold | c41cb73 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 1970 | && (networkRegistrationInfo.getDomain() & domain) != 0) { |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1971 | return new NetworkRegistrationInfo(networkRegistrationInfo); |
Malcolm Chen | 574b41a | 2018-02-13 15:42:58 -0800 | [diff] [blame] | 1972 | } |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1973 | } |
| 1974 | } |
Malcolm Chen | 574b41a | 2018-02-13 15:42:58 -0800 | [diff] [blame] | 1975 | |
Jack Yu | d5f1de1 | 2017-12-21 11:00:05 -0800 | [diff] [blame] | 1976 | return null; |
| 1977 | } |
Malcolm Chen | 574b41a | 2018-02-13 15:42:58 -0800 | [diff] [blame] | 1978 | |
| 1979 | /** |
| 1980 | * @hide |
| 1981 | */ |
Jack Yu | dba1032 | 2019-03-21 16:33:15 -0700 | [diff] [blame] | 1982 | @TestApi |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1983 | public void addNetworkRegistrationInfo(NetworkRegistrationInfo nri) { |
| 1984 | if (nri == null) return; |
Malcolm Chen | 574b41a | 2018-02-13 15:42:58 -0800 | [diff] [blame] | 1985 | |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1986 | synchronized (mNetworkRegistrationInfos) { |
| 1987 | for (int i = 0; i < mNetworkRegistrationInfos.size(); i++) { |
| 1988 | NetworkRegistrationInfo curRegState = mNetworkRegistrationInfos.get(i); |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1989 | if (curRegState.getTransportType() == nri.getTransportType() |
| 1990 | && curRegState.getDomain() == nri.getDomain()) { |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 1991 | mNetworkRegistrationInfos.remove(i); |
Malcolm Chen | 574b41a | 2018-02-13 15:42:58 -0800 | [diff] [blame] | 1992 | break; |
| 1993 | } |
| 1994 | } |
| 1995 | |
Jack Yu | 3753859 | 2019-04-16 08:20:18 -0700 | [diff] [blame] | 1996 | mNetworkRegistrationInfos.add(new NetworkRegistrationInfo(nri)); |
Malcolm Chen | 574b41a | 2018-02-13 15:42:58 -0800 | [diff] [blame] | 1997 | } |
| 1998 | } |
Pengquan Meng | 424acc7 | 2018-11-27 16:45:17 -0800 | [diff] [blame] | 1999 | |
| 2000 | /** |
| 2001 | * @hide |
| 2002 | */ |
| 2003 | public static final int getBetterNRFrequencyRange(int range1, int range2) { |
| 2004 | return FREQUENCY_RANGE_ORDER.indexOf(range1) > FREQUENCY_RANGE_ORDER.indexOf(range2) |
| 2005 | ? range1 |
| 2006 | : range2; |
| 2007 | } |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2008 | |
| 2009 | /** |
| 2010 | * Returns a copy of self with location-identifying information removed. |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 2011 | * Always clears the NetworkRegistrationInfo's CellIdentity fields, but if removeCoarseLocation |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2012 | * is true, clears other info as well. |
Malcolm Chen | 00f7b72 | 2019-12-26 17:11:29 -0800 | [diff] [blame] | 2013 | * |
| 2014 | * @param removeCoarseLocation Whether to also remove coarse location information. |
| 2015 | * if false, it only clears fine location information such as |
| 2016 | * NetworkRegistrationInfo's CellIdentity fields; If true, it will |
| 2017 | * also remove other location information such as operator's MCC |
| 2018 | * and MNC. |
| 2019 | * @return the copied ServiceState with location info sanitized. |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2020 | * @hide |
| 2021 | */ |
Malcolm Chen | 00f7b72 | 2019-12-26 17:11:29 -0800 | [diff] [blame] | 2022 | @NonNull |
| 2023 | public ServiceState createLocationInfoSanitizedCopy(boolean removeCoarseLocation) { |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2024 | ServiceState state = new ServiceState(this); |
Jack Yu | 4c11809 | 2019-05-16 14:27:29 -0700 | [diff] [blame] | 2025 | synchronized (state.mNetworkRegistrationInfos) { |
| 2026 | List<NetworkRegistrationInfo> networkRegistrationInfos = |
| 2027 | state.mNetworkRegistrationInfos.stream() |
| 2028 | .map(NetworkRegistrationInfo::sanitizeLocationInfo) |
| 2029 | .collect(Collectors.toList()); |
| 2030 | state.mNetworkRegistrationInfos.clear(); |
| 2031 | state.mNetworkRegistrationInfos.addAll(networkRegistrationInfos); |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2032 | } |
| 2033 | if (!removeCoarseLocation) return state; |
| 2034 | |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 2035 | state.mOperatorAlphaLong = null; |
| 2036 | state.mOperatorAlphaShort = null; |
| 2037 | state.mOperatorNumeric = null; |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2038 | |
| 2039 | return state; |
| 2040 | } |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 2041 | |
| 2042 | /** |
| 2043 | * @hide |
| 2044 | */ |
| 2045 | public void setOperatorAlphaLongRaw(String operatorAlphaLong) { |
| 2046 | mOperatorAlphaLongRaw = operatorAlphaLong; |
| 2047 | } |
| 2048 | |
| 2049 | /** |
| 2050 | * The current registered raw data network operator name in long alphanumeric format. |
| 2051 | * |
Jayachandran C | 86c4ed7 | 2020-02-27 15:18:33 -0800 | [diff] [blame] | 2052 | * The long format can be up to 16 characters long. |
| 2053 | * |
Jayachandran C | 98e84ea | 2019-11-06 21:55:32 -0800 | [diff] [blame] | 2054 | * @return long raw name of operator, null if unregistered or unknown |
Sarah Chin | b800cbd | 2020-02-19 12:25:36 -0800 | [diff] [blame] | 2055 | * @hide |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 2056 | */ |
Jayachandran C | 98e84ea | 2019-11-06 21:55:32 -0800 | [diff] [blame] | 2057 | @Nullable |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 2058 | public String getOperatorAlphaLongRaw() { |
| 2059 | return mOperatorAlphaLongRaw; |
| 2060 | } |
| 2061 | |
| 2062 | /** |
| 2063 | * @hide |
| 2064 | */ |
| 2065 | public void setOperatorAlphaShortRaw(String operatorAlphaShort) { |
| 2066 | mOperatorAlphaShortRaw = operatorAlphaShort; |
| 2067 | } |
| 2068 | |
| 2069 | /** |
| 2070 | * The current registered raw data network operator name in short alphanumeric format. |
| 2071 | * |
Jayachandran C | 86c4ed7 | 2020-02-27 15:18:33 -0800 | [diff] [blame] | 2072 | * The short format can be up to 8 characters long. |
| 2073 | * |
Jayachandran C | 98e84ea | 2019-11-06 21:55:32 -0800 | [diff] [blame] | 2074 | * @return short raw name of operator, null if unregistered or unknown |
Sarah Chin | b800cbd | 2020-02-19 12:25:36 -0800 | [diff] [blame] | 2075 | * @hide |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 2076 | */ |
Jayachandran C | 98e84ea | 2019-11-06 21:55:32 -0800 | [diff] [blame] | 2077 | @Nullable |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 2078 | public String getOperatorAlphaShortRaw() { |
| 2079 | return mOperatorAlphaShortRaw; |
| 2080 | } |
Jack Yu | a74f2d8 | 2019-05-21 17:16:22 -0700 | [diff] [blame] | 2081 | |
| 2082 | /** |
| 2083 | * Set to {@code true} if any data network is preferred on IWLAN. |
| 2084 | * |
| 2085 | * @param isIwlanPreferred {@code true} if IWLAN is preferred. |
| 2086 | * @hide |
| 2087 | */ |
| 2088 | public void setIwlanPreferred(boolean isIwlanPreferred) { |
| 2089 | mIsIwlanPreferred = isIwlanPreferred; |
| 2090 | } |
Jack Yu | 7ebfc33 | 2019-06-12 11:00:16 -0700 | [diff] [blame] | 2091 | |
| 2092 | /** |
| 2093 | * @return {@code true} if any data network is preferred on IWLAN. |
| 2094 | * |
| 2095 | * Note only when this value is true, {@link #getDataNetworkType()} will return |
| 2096 | * {@link TelephonyManager#NETWORK_TYPE_IWLAN} when AP-assisted mode device camps on both |
| 2097 | * cellular and IWLAN. This value does not affect legacy mode devices as the data network |
| 2098 | * type is directly reported by the modem. |
| 2099 | * |
| 2100 | * @hide |
| 2101 | */ |
| 2102 | public boolean isIwlanPreferred() { |
| 2103 | return mIsIwlanPreferred; |
| 2104 | } |
shilu | c0e176d | 2019-12-02 10:32:00 -0800 | [diff] [blame] | 2105 | |
shilu | 814f189 | 2020-01-24 16:21:56 -0800 | [diff] [blame] | 2106 | /** |
| 2107 | * This indicates whether the device is searching for service. |
| 2108 | * |
| 2109 | * This API reports the modem searching status for |
| 2110 | * {@link AccessNetworkConstants#TRANSPORT_TYPE_WWAN} (cellular) service in either |
| 2111 | * {@link NetworkRegistrationInfo#DOMAIN_CS} or {@link NetworkRegistrationInfo#DOMAIN_PS}. |
| 2112 | * This API will not report searching status for |
| 2113 | * {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN}. |
| 2114 | * |
| 2115 | * @return {@code true} whenever the modem is searching for service. |
| 2116 | */ |
shilu | c0e176d | 2019-12-02 10:32:00 -0800 | [diff] [blame] | 2117 | public boolean isSearching() { |
| 2118 | NetworkRegistrationInfo psRegState = getNetworkRegistrationInfo( |
| 2119 | NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
| 2120 | |
| 2121 | if (psRegState != null && psRegState.getRegistrationState() |
| 2122 | == NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_SEARCHING) { |
| 2123 | return true; |
| 2124 | } |
| 2125 | |
| 2126 | NetworkRegistrationInfo csRegState = getNetworkRegistrationInfo( |
| 2127 | NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); |
| 2128 | |
| 2129 | if (csRegState != null && csRegState.getRegistrationState() |
| 2130 | == NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_SEARCHING) { |
| 2131 | return true; |
| 2132 | } |
| 2133 | return false; |
| 2134 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2135 | } |