blob: 186e7b64839deb875259f7b49a6a192105a3b18d [file] [log] [blame]
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001/*
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
17package com.android.phone;
18
Jordan Liuff2ccd72019-07-23 15:54:41 -070019import android.annotation.IntDef;
Ling Ma317906d2022-12-05 15:58:14 -080020import android.annotation.Nullable;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070021import android.app.Activity;
22import android.app.KeyguardManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070023import android.app.ProgressDialog;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070024import android.content.BroadcastReceiver;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070025import android.content.ContentResolver;
26import android.content.Context;
27import android.content.ContextWrapper;
28import android.content.Intent;
29import android.content.IntentFilter;
Brad Ebinger05f52c22019-12-05 13:03:21 -080030import android.content.pm.PackageManager;
Youming Ye47a6adc2018-11-19 15:33:36 -080031import android.content.res.XmlResourceParser;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070032import android.media.AudioManager;
Santos Cordone18902f2016-03-22 17:16:04 -070033import android.net.ConnectivityManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070034import android.net.Uri;
35import android.os.AsyncResult;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070036import android.os.Handler;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070037import android.os.Message;
Jonathan Basseric31f1f32015-05-12 10:13:03 -070038import android.os.PersistableBundle;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070039import android.os.PowerManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070040import android.os.SystemProperties;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070041import android.preference.PreferenceManager;
Sanket Padawe4c699232016-02-09 11:07:22 -080042import android.provider.Settings;
Meng Wang61307622019-10-23 14:08:43 -070043import android.sysprop.TelephonyProperties;
Tyler Gunn900d8fd2018-09-21 09:22:12 -070044import android.telecom.TelecomManager;
Nathan Haroldf9df6ea2019-03-08 11:54:22 -080045import android.telephony.AnomalyReporter;
Junda Liu12f7d802015-05-01 12:06:44 -070046import android.telephony.CarrierConfigManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070047import android.telephony.ServiceState;
chen xubaf9fe52019-07-02 17:28:24 -070048import android.telephony.SubscriptionInfo;
Andrew Lee385019f2014-11-24 14:19:50 -080049import android.telephony.SubscriptionManager;
Sarah Chin072ffb22022-05-03 17:58:59 -070050import android.telephony.TelephonyCallback;
Hall Liuaa4211e2021-01-20 15:43:39 -080051import android.telephony.TelephonyLocalConnection;
Jack Yu1a2fc352017-07-14 17:14:37 -070052import android.telephony.TelephonyManager;
Ling Ma317906d2022-12-05 15:58:14 -080053import android.util.ArraySet;
Jack Yu1a2fc352017-07-14 17:14:37 -070054import android.util.LocalLog;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070055import android.util.Log;
Santos Cordone18902f2016-03-22 17:16:04 -070056import android.widget.Toast;
Ta-wei Yenb29425b2016-09-21 17:28:14 -070057
Brad Ebingere3ae65a2020-09-11 12:45:11 -070058import com.android.ims.ImsFeatureBinderRepository;
Siim Sammul182d61b2021-05-04 16:01:42 +010059import com.android.internal.os.BinderCallsStats;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070060import com.android.internal.telephony.CallManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070061import com.android.internal.telephony.IccCardConstants;
62import com.android.internal.telephony.MmiCode;
63import com.android.internal.telephony.Phone;
Sarah Chin072ffb22022-05-03 17:58:59 -070064import com.android.internal.telephony.PhoneConfigurationManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070065import com.android.internal.telephony.PhoneConstants;
66import com.android.internal.telephony.PhoneFactory;
Jack Yu1a2fc352017-07-14 17:14:37 -070067import com.android.internal.telephony.SettingsObserver;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070068import com.android.internal.telephony.TelephonyCapabilities;
Youming Ye47a6adc2018-11-19 15:33:36 -080069import com.android.internal.telephony.TelephonyComponentFactory;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070070import com.android.internal.telephony.TelephonyIntents;
Jack Yu3e2ac6e2022-03-26 13:59:45 -070071import com.android.internal.telephony.data.DataEvaluation.DataDisallowedReason;
Hwangoo Parkba21cf22022-11-30 14:34:04 +000072import com.android.internal.telephony.domainselection.DomainSelectionResolver;
Brad Ebinger05f52c22019-12-05 13:03:21 -080073import com.android.internal.telephony.ims.ImsResolver;
Tyler Gunn92479152021-01-20 16:30:10 -080074import com.android.internal.telephony.imsphone.ImsPhone;
75import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +000076import com.android.internal.telephony.uicc.UiccPort;
Jordan Liu06bdef12021-03-24 17:25:46 -070077import com.android.internal.telephony.uicc.UiccProfile;
Jack Yu1a2fc352017-07-14 17:14:37 -070078import com.android.internal.util.IndentingPrintWriter;
Andrew Leefb7f92e2015-02-26 16:23:32 -080079import com.android.phone.settings.SettingsConstants;
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -070080import com.android.phone.vvm.CarrierVvmPackageInstalledReceiver;
Hwangoo Parkba21cf22022-11-30 14:34:04 +000081import com.android.services.telephony.domainselection.TelephonyDomainSelectionService;
James.cf Linc9f35a42020-01-15 02:35:22 +080082import com.android.services.telephony.rcs.TelephonyRcsService;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070083
Jack Yu1a2fc352017-07-14 17:14:37 -070084import java.io.FileDescriptor;
85import java.io.PrintWriter;
Jordan Liuff2ccd72019-07-23 15:54:41 -070086import java.lang.annotation.Retention;
87import java.lang.annotation.RetentionPolicy;
chen xubaf9fe52019-07-02 17:28:24 -070088import java.util.List;
Jack Yu1a2fc352017-07-14 17:14:37 -070089
Santos Cordon7d4ddf62013-07-10 11:58:08 -070090/**
91 * Global state for the telephony subsystem when running in the primary
92 * phone process.
93 */
Sailesh Nepalbf900542014-07-15 16:18:32 -070094public class PhoneGlobals extends ContextWrapper {
Jack Yu1a2fc352017-07-14 17:14:37 -070095 public static final String LOG_TAG = "PhoneGlobals";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070096
97 /**
98 * Phone app-wide debug level:
99 * 0 - no debug logging
100 * 1 - normal debug logging if ro.debuggable is set (which is true in
101 * "eng" and "userdebug" builds but not "user" builds)
102 * 2 - ultra-verbose debug logging
103 *
104 * Most individual classes in the phone app have a local DBG constant,
105 * typically set to
106 * (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1)
107 * or else
108 * (PhoneApp.DBG_LEVEL >= 2)
109 * depending on the desired verbosity.
110 *
111 * ***** DO NOT SUBMIT WITH DBG_LEVEL > 0 *************
112 */
Andrew Lee88b51e22014-10-29 15:48:51 -0700113 public static final int DBG_LEVEL = 0;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700114
115 private static final boolean DBG =
116 (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
117 private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
118
119 // Message codes; see mHandler below.
120 private static final int EVENT_SIM_NETWORK_LOCKED = 3;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700121 private static final int EVENT_SIM_STATE_CHANGED = 8;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700122 private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10;
Jordan Liuff2ccd72019-07-23 15:54:41 -0700123 private static final int EVENT_DATA_ROAMING_CONNECTED = 11;
124 private static final int EVENT_DATA_ROAMING_OK = 12;
125 private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 13;
Jordan Liuff2ccd72019-07-23 15:54:41 -0700126 private static final int EVENT_DATA_ROAMING_SETTINGS_CHANGED = 15;
127 private static final int EVENT_MOBILE_DATA_SETTINGS_CHANGED = 16;
Lei Liu863eac02020-06-24 20:12:55 +0800128 private static final int EVENT_CARRIER_CONFIG_CHANGED = 17;
Sarah Chin072ffb22022-05-03 17:58:59 -0700129 private static final int EVENT_MULTI_SIM_CONFIG_CHANGED = 18;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700130
131 // The MMI codes are also used by the InCallScreen.
132 public static final int MMI_INITIATE = 51;
133 public static final int MMI_COMPLETE = 52;
134 public static final int MMI_CANCEL = 53;
135 // Don't use message codes larger than 99 here; those are reserved for
136 // the individual Activities of the Phone UI.
137
Santos Cordone18902f2016-03-22 17:16:04 -0700138 public static final int AIRPLANE_ON = 1;
139 public static final int AIRPLANE_OFF = 0;
140
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700141 /**
142 * Allowable values for the wake lock code.
143 * SLEEP means the device can be put to sleep.
144 * PARTIAL means wake the processor, but we display can be kept off.
145 * FULL means wake both the processor and the display.
146 */
147 public enum WakeState {
148 SLEEP,
149 PARTIAL,
150 FULL
151 }
152
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700153 private static PhoneGlobals sMe;
154
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700155 CallManager mCM;
Santos Cordon63a84242013-07-23 13:32:52 -0700156 CallNotifier notifier;
Santos Cordon63a84242013-07-23 13:32:52 -0700157 NotificationMgr notificationMgr;
James.cf Linc9f35a42020-01-15 02:35:22 +0800158 TelephonyRcsService mTelephonyRcsService;
Andrew Lee9431b832015-03-09 18:46:45 -0700159 public PhoneInterfaceManager phoneMgr;
James.cf Linaf3183c2019-10-24 00:59:00 +0800160 public ImsRcsController imsRcsController;
Hunsuk Choi3b742d62021-10-25 19:48:34 +0000161 public ImsStateCallbackController mImsStateCallbackController;
joonhunshincffb7fc2021-11-28 07:32:01 +0000162 public ImsProvisioningController mImsProvisioningController;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800163 CarrierConfigLoader configLoader;
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000164 TelephonyDomainSelectionService mDomainSelectionService;
Santos Cordon63a84242013-07-23 13:32:52 -0700165
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530166 private Phone phoneInEcm;
Santos Cordon63a84242013-07-23 13:32:52 -0700167
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700168 static boolean sVoiceCapable = true;
169
Santos Cordonc593d002015-06-03 15:41:15 -0700170 // TODO: Remove, no longer used.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700171 CdmaPhoneCallState cdmaPhoneCallState;
172
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700173 // The currently-active PUK entry activity and progress dialog.
174 // Normally, these are the Emergency Dialer and the subsequent
175 // progress dialog. null if there is are no such objects in
176 // the foreground.
177 private Activity mPUKEntryActivity;
178 private ProgressDialog mPUKEntryProgressDialog;
179
Jordan Liuff2ccd72019-07-23 15:54:41 -0700180 /** @hide */
181 @Retention(RetentionPolicy.SOURCE)
182 @IntDef(prefix = {"ROAMING_NOTIFICATION_"},
183 value = {
184 ROAMING_NOTIFICATION_NO_NOTIFICATION,
185 ROAMING_NOTIFICATION_CONNECTED,
186 ROAMING_NOTIFICATION_DISCONNECTED})
187 public @interface RoamingNotification {}
188
189 private static final int ROAMING_NOTIFICATION_NO_NOTIFICATION = 0;
190 private static final int ROAMING_NOTIFICATION_CONNECTED = 1;
191 private static final int ROAMING_NOTIFICATION_DISCONNECTED = 2;
192
193 @RoamingNotification
194 private int mPrevRoamingNotification = ROAMING_NOTIFICATION_NO_NOTIFICATION;
Jack Yu953f9352017-05-18 14:41:06 -0700195
Ling Ma317906d2022-12-05 15:58:14 -0800196 /** Operator numerics for which we've shown is-roaming notifications. **/
197 private ArraySet<String> mPrevRoamingOperatorNumerics = new ArraySet<>();
198
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700199 private WakeState mWakeState = WakeState.SLEEP;
200
201 private PowerManager mPowerManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700202 private PowerManager.WakeLock mWakeLock;
203 private PowerManager.WakeLock mPartialWakeLock;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700204 private KeyguardManager mKeyguardManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700205
Jack Yu1a2fc352017-07-14 17:14:37 -0700206 private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
207 private final LocalLog mDataRoamingNotifLog = new LocalLog(50);
208
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700209 // Broadcast receiver for various intent broadcasts (see onCreate())
210 private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver();
211
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -0700212 private final CarrierVvmPackageInstalledReceiver mCarrierVvmPackageInstalledReceiver =
213 new CarrierVvmPackageInstalledReceiver();
214
Jack Yu1a2fc352017-07-14 17:14:37 -0700215 private final SettingsObserver mSettingsObserver;
Siim Sammul182d61b2021-05-04 16:01:42 +0100216 private BinderCallsStats.SettingsObserver mBinderCallsSettingsObserver;
Jack Yu1a2fc352017-07-14 17:14:37 -0700217
Sarah Chin072ffb22022-05-03 17:58:59 -0700218 // Mapping of phone ID to the associated TelephonyCallback. These should be registered without
219 // fine or coarse location since we only use ServiceState for
220 private PhoneAppCallback[] mTelephonyCallbacks;
221
222 private class PhoneAppCallback extends TelephonyCallback implements
223 TelephonyCallback.ServiceStateListener {
224 private final int mSubId;
225
226 PhoneAppCallback(int subId) {
227 mSubId = subId;
228 }
229
230 @Override
231 public void onServiceStateChanged(ServiceState serviceState) {
232 // Note when registering that we should be registering with INCLUDE_LOCATION_DATA_NONE.
233 // PhoneGlobals only uses the state and roaming status, which does not require location.
234 handleServiceStateChanged(serviceState, mSubId);
235 }
236
237 public int getSubId() {
238 return mSubId;
239 }
240 }
241
Nazish Tabassum160d2112019-12-23 17:31:33 +0530242 private static class EventSimStateChangedBag {
243 final int mPhoneId;
244 final String mIccStatus;
245
246 EventSimStateChangedBag(int phoneId, String iccStatus) {
247 mPhoneId = phoneId;
248 mIccStatus = iccStatus;
249 }
250 }
251
Jordan Liu06bdef12021-03-24 17:25:46 -0700252 // Some carrier config settings disable the network lock screen, so we call handleSimLock
253 // when either SIM_LOCK or CARRIER_CONFIG changes so that no matter which one happens first,
254 // we still do the right thing
255 private void handleSimLock(int subType, Phone phone) {
256 PersistableBundle cc = getCarrierConfigForSubId(phone.getSubId());
257 if (!CarrierConfigManager.isConfigForIdentifiedCarrier(cc)) {
258 // If we only have the default carrier config just return, to avoid popping up the
259 // the SIM lock screen when it's disabled by the carrier.
260 Log.i(LOG_TAG, "Not showing 'SIM network unlock' screen. Carrier config not loaded");
261 return;
262 }
263 if (cc.getBoolean(CarrierConfigManager.KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL)) {
264 // Some products don't have the concept of a "SIM network lock"
265 Log.i(LOG_TAG, "Not showing 'SIM network unlock' screen. Disabled by carrier config");
266 return;
267 }
268
269 // if passed in subType is unknown, retrieve it here.
270 if (subType == -1) {
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +0000271 final UiccPort uiccPort = phone.getUiccPort();
272 if (uiccPort == null) {
Jordan Liu06bdef12021-03-24 17:25:46 -0700273 Log.e(LOG_TAG,
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +0000274 "handleSimLock: uiccPort for phone " + phone.getPhoneId() + " is null");
Jordan Liu06bdef12021-03-24 17:25:46 -0700275 return;
276 }
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +0000277 final UiccProfile uiccProfile = uiccPort.getUiccProfile();
Jordan Liu06bdef12021-03-24 17:25:46 -0700278 if (uiccProfile == null) {
279 Log.e(LOG_TAG,
280 "handleSimLock: uiccProfile for phone " + phone.getPhoneId() + " is null");
281 return;
282 }
283 subType = uiccProfile.getApplication(
284 uiccProfile.mCurrentAppType).getPersoSubState().ordinal();
285 }
286 // Normal case: show the "SIM network unlock" PIN entry screen.
287 // The user won't be able to do anything else until
288 // they enter a valid SIM network PIN.
289 Log.i(LOG_TAG, "show sim depersonal panel");
290 IccNetworkDepersonalizationPanel.showDialog(phone, subType);
291 }
292
293 private boolean isSimLocked(Phone phone) {
294 TelephonyManager tm = getSystemService(TelephonyManager.class);
295 return tm.createForSubscriptionId(phone.getSubId()).getSimState()
296 == TelephonyManager.SIM_STATE_NETWORK_LOCKED;
297 }
298
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700299 Handler mHandler = new Handler() {
300 @Override
301 public void handleMessage(Message msg) {
302 PhoneConstants.State phoneState;
Jack Yu1a2fc352017-07-14 17:14:37 -0700303 if (VDBG) Log.v(LOG_TAG, "event=" + msg.what);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700304 switch (msg.what) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700305 // TODO: This event should be handled by the lock screen, just
306 // like the "SIM missing" and "Sim locked" cases (bug 1804111).
307 case EVENT_SIM_NETWORK_LOCKED:
Jordan Liu06bdef12021-03-24 17:25:46 -0700308 int subType = (Integer) ((AsyncResult) msg.obj).result;
309 Phone phone = (Phone) ((AsyncResult) msg.obj).userObj;
310 handleSimLock(subType, phone);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700311 break;
312
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700313 case EVENT_DATA_ROAMING_DISCONNECTED:
Jordan Liuff2ccd72019-07-23 15:54:41 -0700314 notificationMgr.showDataRoamingNotification(msg.arg1, false);
315 break;
316
317 case EVENT_DATA_ROAMING_CONNECTED:
318 notificationMgr.showDataRoamingNotification(msg.arg1, true);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700319 break;
320
321 case EVENT_DATA_ROAMING_OK:
Jordan Liuff2ccd72019-07-23 15:54:41 -0700322 notificationMgr.hideDataRoamingNotification();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700323 break;
324
325 case MMI_COMPLETE:
326 onMMIComplete((AsyncResult) msg.obj);
327 break;
328
329 case MMI_CANCEL:
Stuart Scottdcf40a92014-12-09 10:45:01 -0800330 PhoneUtils.cancelMmiCode(mCM.getFgPhone());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700331 break;
332
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700333 case EVENT_SIM_STATE_CHANGED:
334 // Marks the event where the SIM goes into ready state.
335 // Right now, this is only used for the PUK-unlocking
336 // process.
Nazish Tabassum160d2112019-12-23 17:31:33 +0530337 EventSimStateChangedBag bag = (EventSimStateChangedBag)msg.obj;
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700338 if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(bag.mIccStatus)
Nazish Tabassum59126a92020-07-03 21:44:49 +0530339 || IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(bag.mIccStatus)
340 || IccCardConstants.INTENT_VALUE_ICC_NOT_READY.equals(bag.mIccStatus)
341 || IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(bag.mIccStatus)) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700342 // when the right event is triggered and there
343 // are UI objects in the foreground, we close
344 // them to display the lock panel.
345 if (mPUKEntryActivity != null) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700346 Log.i(LOG_TAG, "Dismiss puk entry activity");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700347 mPUKEntryActivity.finish();
348 mPUKEntryActivity = null;
349 }
350 if (mPUKEntryProgressDialog != null) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700351 Log.i(LOG_TAG, "Dismiss puk progress dialog");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700352 mPUKEntryProgressDialog.dismiss();
353 mPUKEntryProgressDialog = null;
354 }
Nazish Tabassum59126a92020-07-03 21:44:49 +0530355 Log.i(LOG_TAG, "Dismissing depersonal panel" + (bag.mIccStatus));
Nazish Tabassum160d2112019-12-23 17:31:33 +0530356 IccNetworkDepersonalizationPanel.dialogDismiss(bag.mPhoneId);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700357 }
358 break;
359
360 case EVENT_UNSOL_CDMA_INFO_RECORD:
361 //TODO: handle message here;
362 break;
Jack Yu1a2fc352017-07-14 17:14:37 -0700363 case EVENT_DATA_ROAMING_SETTINGS_CHANGED:
364 case EVENT_MOBILE_DATA_SETTINGS_CHANGED:
365 updateDataRoamingStatus();
366 break;
Lei Liu863eac02020-06-24 20:12:55 +0800367 case EVENT_CARRIER_CONFIG_CHANGED:
368 int subId = (Integer) msg.obj;
369 // The voicemail number could be overridden by carrier config, so need to
370 // refresh the message waiting (voicemail) indicator.
371 refreshMwiIndicator(subId);
Jordan Liu06bdef12021-03-24 17:25:46 -0700372 phone = getPhone(subId);
Sarah Chin072ffb22022-05-03 17:58:59 -0700373 if (phone != null) {
374 if (isSimLocked(phone)) {
375 // pass in subType=-1 so handleSimLock can find the actual subType if
376 // needed. This is safe as valid values for subType are >= 0
377 handleSimLock(-1, phone);
378 }
379 TelephonyManager tm = getSystemService(TelephonyManager.class);
380 PhoneAppCallback callback = mTelephonyCallbacks[phone.getPhoneId()];
381 // TODO: We may need to figure out a way to unregister if subId is invalid
382 tm.createForSubscriptionId(callback.getSubId())
383 .unregisterTelephonyCallback(callback);
384 callback = new PhoneAppCallback(subId);
385 tm.createForSubscriptionId(subId).registerTelephonyCallback(
Ling Ma317906d2022-12-05 15:58:14 -0800386 TelephonyManager.INCLUDE_LOCATION_DATA_COARSE, mHandler::post,
Sarah Chin072ffb22022-05-03 17:58:59 -0700387 callback);
388 mTelephonyCallbacks[phone.getPhoneId()] = callback;
389 }
390 break;
391 case EVENT_MULTI_SIM_CONFIG_CHANGED:
392 int activeModems = (int) ((AsyncResult) msg.obj).result;
393 TelephonyManager tm = getSystemService(TelephonyManager.class);
394 // Unregister all previous callbacks
395 for (int phoneId = 0; phoneId < mTelephonyCallbacks.length; phoneId++) {
396 PhoneAppCallback callback = mTelephonyCallbacks[phoneId];
397 if (callback != null) {
398 tm.createForSubscriptionId(callback.getSubId())
399 .unregisterTelephonyCallback(callback);
400 mTelephonyCallbacks[phoneId] = null;
401 }
402 }
403 // Register callbacks for all active modems
404 for (int phoneId = 0; phoneId < activeModems; phoneId++) {
405 int sub = PhoneFactory.getPhone(phoneId).getSubId();
406 PhoneAppCallback callback = new PhoneAppCallback(sub);
407 tm.createForSubscriptionId(sub).registerTelephonyCallback(
408 TelephonyManager.INCLUDE_LOCATION_DATA_NONE, mHandler::post,
409 callback);
410 mTelephonyCallbacks[phoneId] = callback;
Jordan Liu06bdef12021-03-24 17:25:46 -0700411 }
Lei Liu863eac02020-06-24 20:12:55 +0800412 break;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700413 }
414 }
415 };
416
417 public PhoneGlobals(Context context) {
418 super(context);
419 sMe = this;
Jack Yu1a2fc352017-07-14 17:14:37 -0700420 mSettingsObserver = new SettingsObserver(context, mHandler);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700421 }
422
423 public void onCreate() {
424 if (VDBG) Log.v(LOG_TAG, "onCreate()...");
425
426 ContentResolver resolver = getContentResolver();
427
Hall Liuaa4211e2021-01-20 15:43:39 -0800428 // Initialize the shim from frameworks/opt/telephony into packages/services/Telephony.
429 TelephonyLocalConnection.setInstance(new LocalConnectionImpl(this));
430
Sarah Chin072ffb22022-05-03 17:58:59 -0700431 TelephonyManager tm = getSystemService(TelephonyManager.class);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700432 // Cache the "voice capable" flag.
433 // This flag currently comes from a resource (which is
434 // overrideable on a per-product basis):
Sarah Chin072ffb22022-05-03 17:58:59 -0700435 sVoiceCapable = tm.isVoiceCapable();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700436 // ...but this might eventually become a PackageManager "system
437 // feature" instead, in which case we'd do something like:
438 // sVoiceCapable =
439 // getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_VOICE_CALLS);
440
Stuart Scottdcf40a92014-12-09 10:45:01 -0800441 if (mCM == null) {
Nathan Haroldf9df6ea2019-03-08 11:54:22 -0800442 // Initialize AnomalyReporter early so that it can be used
443 AnomalyReporter.initialize(this);
Nathan Harold0db5c5e2019-01-22 20:18:56 -0800444
Youming Ye47a6adc2018-11-19 15:33:36 -0800445 // Inject telephony component factory if configured using other jars.
446 XmlResourceParser parser = getResources().getXml(R.xml.telephony_injection);
447 TelephonyComponentFactory.getInstance().injectTheComponentFactory(parser);
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000448
449 // Create DomainSelectionResolver always, but it MUST be initialized only when
450 // the device supports AOSP domain selection architecture and
451 // has new IRadio that supports its related HAL APIs.
452 DomainSelectionResolver.make(this,
453 getResources().getBoolean(R.bool.config_enable_aosp_domain_selection));
454
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700455 // Initialize the telephony framework
456 PhoneFactory.makeDefaultPhones(this);
457
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000458 // Initialize the DomainSelectionResolver after creating the Phone instance
459 // to check the Radio HAL version.
460 if (DomainSelectionResolver.getInstance().isDomainSelectionSupported()) {
461 mDomainSelectionService = new TelephonyDomainSelectionService(this);
462 DomainSelectionResolver.getInstance().initialize(mDomainSelectionService);
463 }
464
Brad Ebinger05f52c22019-12-05 13:03:21 -0800465 // Only bring up ImsResolver if the device supports having an IMS stack.
466 if (getPackageManager().hasSystemFeature(
467 PackageManager.FEATURE_TELEPHONY_IMS)) {
468 // Get the package name of the default IMS implementation.
469 String defaultImsMmtelPackage = getResources().getString(
470 R.string.config_ims_mmtel_package);
471 String defaultImsRcsPackage = getResources().getString(
472 R.string.config_ims_rcs_package);
Brad Ebingerd1947d82021-05-17 20:54:49 +0000473 ImsResolver.make(this, defaultImsMmtelPackage,
Brad Ebingere3ae65a2020-09-11 12:45:11 -0700474 defaultImsRcsPackage, PhoneFactory.getPhones().length,
475 new ImsFeatureBinderRepository());
Brad Ebingerd1947d82021-05-17 20:54:49 +0000476 ImsResolver.getInstance().initialize();
Tyler Gunn92479152021-01-20 16:30:10 -0800477
478 // With the IMS phone created, load static config.xml values from the phone process
479 // so that it can be provided to the ImsPhoneCallTracker.
480 for (Phone p : PhoneFactory.getPhones()) {
481 Phone imsPhone = p.getImsPhone();
482 if (imsPhone != null && imsPhone instanceof ImsPhone) {
483 ImsPhone theImsPhone = (ImsPhone) imsPhone;
484 if (theImsPhone.getCallTracker() instanceof ImsPhoneCallTracker) {
485 ImsPhoneCallTracker ict = (ImsPhoneCallTracker)
486 theImsPhone.getCallTracker();
487
488 ImsPhoneCallTracker.Config config = new ImsPhoneCallTracker.Config();
489 config.isD2DCommunicationSupported = getResources().getBoolean(
490 R.bool.config_use_device_to_device_communication);
491 ict.setConfig(config);
492 }
493 }
494 }
Hui Wang068ab862020-10-31 05:12:53 +0000495 RcsProvisioningMonitor.make(this);
Brad Ebinger05f52c22019-12-05 13:03:21 -0800496 }
497
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700498 // Start TelephonyDebugService After the default phone is created.
499 Intent intent = new Intent(this, TelephonyDebugService.class);
500 startService(intent);
501
502 mCM = CallManager.getInstance();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700503
504 // Create the NotificationMgr singleton, which is used to display
505 // status bar icons and control other status bar behavior.
506 notificationMgr = NotificationMgr.init(this);
507
Anthony Lee03ebdfc2015-07-27 08:12:02 -0700508 // Create an instance of CdmaPhoneCallState and initialize it to IDLE
509 cdmaPhoneCallState = new CdmaPhoneCallState();
510 cdmaPhoneCallState.CdmaPhoneCallStateInit();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700511
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700512 // before registering for phone state changes
513 mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
514 mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, LOG_TAG);
515 // lock used to keep the processor awake, when we don't care for the display.
516 mPartialWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
517 | PowerManager.ON_AFTER_RELEASE, LOG_TAG);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700518
519 mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
520
Nazanin Bakhshi2f2cc692018-12-11 15:15:39 -0800521 phoneMgr = PhoneInterfaceManager.init(this);
Santos Cordon406c0342013-08-28 00:07:47 -0700522
James.cf Linaf3183c2019-10-24 00:59:00 +0800523 imsRcsController = ImsRcsController.init(this);
524
James.cf Linc9f35a42020-01-15 02:35:22 +0800525 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS)) {
Hunsuk Choi3b742d62021-10-25 19:48:34 +0000526 mImsStateCallbackController =
527 ImsStateCallbackController.make(this, PhoneFactory.getPhones().length);
Brad Ebingera68a4972020-01-30 17:31:23 -0800528 mTelephonyRcsService = new TelephonyRcsService(this,
529 PhoneFactory.getPhones().length);
530 mTelephonyRcsService.initialize();
James.cf Linc9f35a42020-01-15 02:35:22 +0800531 imsRcsController.setRcsService(mTelephonyRcsService);
joonhunshincffb7fc2021-11-28 07:32:01 +0000532 mImsProvisioningController =
533 ImsProvisioningController.make(this, PhoneFactory.getPhones().length);
James.cf Linc9f35a42020-01-15 02:35:22 +0800534 }
535
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800536 configLoader = CarrierConfigLoader.init(this);
537
Jack Yu1a2fc352017-07-14 17:14:37 -0700538 // Create the CallNotifier singleton, which handles
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700539 // asynchronous events from the telephony layer (like
540 // launching the incoming-call UI when an incoming call comes
541 // in.)
Brad Ebingera9c6b6d2016-01-07 17:24:16 -0800542 notifier = CallNotifier.init(this);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700543
Stuart Scottdcf40a92014-12-09 10:45:01 -0800544 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700545
546 // register for MMI/USSD
547 mCM.registerForMmiComplete(mHandler, MMI_COMPLETE, null);
548
Qiong Liucc3fe812019-09-23 15:25:44 +0800549 // Initialize cell status using current airplane mode.
Taesu Lee62f826d2020-08-10 16:01:18 +0900550 handleAirplaneModeChange(
551 Settings.Global.getInt(
552 getContentResolver(),
553 Settings.Global.AIRPLANE_MODE_ON,
554 AIRPLANE_OFF)
555 == AIRPLANE_ON);
Qiong Liucc3fe812019-09-23 15:25:44 +0800556
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700557 // Register for misc other intent broadcasts.
558 IntentFilter intentFilter =
559 new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700560 intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
561 intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700562 intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
Jack Yu1a2fc352017-07-14 17:14:37 -0700563 intentFilter.addAction(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
564 intentFilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700565 registerReceiver(mReceiver, intentFilter);
566
Sarah Chin072ffb22022-05-03 17:58:59 -0700567 PhoneConfigurationManager.registerForMultiSimConfigChange(
568 mHandler, EVENT_MULTI_SIM_CONFIG_CHANGED, null);
569
570 mTelephonyCallbacks = new PhoneAppCallback[tm.getSupportedModemCount()];
Fangyuan Li7f5c2752022-06-29 18:02:31 +0800571 if (tm.getSupportedModemCount() > 0) {
572 for (Phone phone : PhoneFactory.getPhones()) {
573 int subId = phone.getSubId();
574 PhoneAppCallback callback = new PhoneAppCallback(subId);
575 tm.createForSubscriptionId(subId).registerTelephonyCallback(
576 TelephonyManager.INCLUDE_LOCATION_DATA_NONE, mHandler::post, callback);
577 mTelephonyCallbacks[phone.getPhoneId()] = callback;
578 }
Sarah Chin072ffb22022-05-03 17:58:59 -0700579 }
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -0700580 mCarrierVvmPackageInstalledReceiver.register(this);
581
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700582 //set the default values for the preferences in the phone.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700583 PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700584 }
585
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700586 // XXX pre-load the SimProvider so that it's ready
587 resolver.getType(Uri.parse("content://icc/adn"));
588
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700589 // TODO: Register for Cdma Information Records
590 // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null);
591
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700592 // Read HAC settings and configure audio hardware
593 if (getResources().getBoolean(R.bool.hac_enabled)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800594 int hac = android.provider.Settings.System.getInt(
595 getContentResolver(),
596 android.provider.Settings.System.HEARING_AID,
597 0);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700598 AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
Jordan Liuf71aeef2019-08-21 11:46:09 -0700599 audioManager.setParameters(
600 SettingsConstants.HAC_KEY + "=" + (hac == SettingsConstants.HAC_ENABLED
601 ? SettingsConstants.HAC_VAL_ON : SettingsConstants.HAC_VAL_OFF));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700602 }
Siim Sammul182d61b2021-05-04 16:01:42 +0100603
604 // Start tracking Binder latency for the phone process.
605 mBinderCallsSettingsObserver = new BinderCallsStats.SettingsObserver(
606 getApplicationContext(),
Siim Sammula6950092021-06-22 17:14:03 +0100607 new BinderCallsStats(
608 new BinderCallsStats.Injector(),
609 com.android.internal.os.BinderLatencyProto.Dims.TELEPHONY));
Santos Cordonff506f52013-11-21 19:13:19 -0800610 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700611
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700612 /**
613 * Returns the singleton instance of the PhoneApp.
614 */
Sailesh Nepal1eaf22b2014-02-22 17:00:49 -0800615 public static PhoneGlobals getInstance() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700616 if (sMe == null) {
617 throw new IllegalStateException("No PhoneGlobals here!");
618 }
619 return sMe;
620 }
621
622 /**
Stuart Scottdcf40a92014-12-09 10:45:01 -0800623 * Returns the default phone.
624 *
Andrew Lee385019f2014-11-24 14:19:50 -0800625 * WARNING: This method should be used carefully, now that there may be multiple phones.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700626 */
Andrew Lee83383e42014-10-31 12:42:28 -0700627 public static Phone getPhone() {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800628 return PhoneFactory.getDefaultPhone();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700629 }
630
Andrew Lee2fcb6c32014-12-04 14:52:35 -0800631 public static Phone getPhone(int subId) {
632 return PhoneFactory.getPhone(SubscriptionManager.getPhoneId(subId));
Andrew Lee385019f2014-11-24 14:19:50 -0800633 }
634
Santos Cordonde10b752013-09-19 04:11:33 -0700635 /* package */ CallManager getCallManager() {
636 return mCM;
637 }
638
Chris Manton4e9fa912015-06-19 11:26:57 -0700639 public PersistableBundle getCarrierConfig() {
Shishir Agrawald3480e02016-01-25 13:05:49 -0800640 return getCarrierConfigForSubId(SubscriptionManager.getDefaultSubscriptionId());
Jonathan Basseri89b0ab42015-05-01 10:52:40 -0700641 }
642
Chris Manton4e9fa912015-06-19 11:26:57 -0700643 public PersistableBundle getCarrierConfigForSubId(int subId) {
Philip P. Moltmann0079aae2020-03-05 16:24:02 -0800644 return configLoader.getConfigForSubIdWithFeature(subId, getOpPackageName(),
645 getAttributionTag());
Junda Liu605148f2015-04-28 15:23:40 -0700646 }
647
Jack Yu1a2fc352017-07-14 17:14:37 -0700648 private void registerSettingsObserver() {
649 mSettingsObserver.unobserve();
650 String dataRoamingSetting = Settings.Global.DATA_ROAMING;
651 String mobileDataSetting = Settings.Global.MOBILE_DATA;
652 if (TelephonyManager.getDefault().getSimCount() > 1) {
653 int subId = mDefaultDataSubId;
654 if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
655 dataRoamingSetting += subId;
656 mobileDataSetting += subId;
657 }
658 }
659
660 // Listen for user data roaming setting changed event
661 mSettingsObserver.observe(Settings.Global.getUriFor(dataRoamingSetting),
662 EVENT_DATA_ROAMING_SETTINGS_CHANGED);
663
664 // Listen for mobile data setting changed event
665 mSettingsObserver.observe(Settings.Global.getUriFor(mobileDataSetting),
666 EVENT_MOBILE_DATA_SETTINGS_CHANGED);
667 }
668
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700669 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700670 * Sets the activity responsible for un-PUK-blocking the device
671 * so that we may close it when we receive a positive result.
672 * mPUKEntryActivity is also used to indicate to the device that
673 * we are trying to un-PUK-lock the phone. In other words, iff
674 * it is NOT null, then we are trying to unlock and waiting for
675 * the SIM to move to READY state.
676 *
677 * @param activity is the activity to close when PUK has
678 * finished unlocking. Can be set to null to indicate the unlock
679 * or SIM READYing process is over.
680 */
681 void setPukEntryActivity(Activity activity) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700682 Log.i(LOG_TAG, "setPukEntryActivity - set to " + (activity == null ? "null" : "activity"));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700683 mPUKEntryActivity = activity;
684 }
685
686 Activity getPUKEntryActivity() {
687 return mPUKEntryActivity;
688 }
689
690 /**
691 * Sets the dialog responsible for notifying the user of un-PUK-
692 * blocking - SIM READYing progress, so that we may dismiss it
693 * when we receive a positive result.
694 *
695 * @param dialog indicates the progress dialog informing the user
696 * of the state of the device. Dismissed upon completion of
697 * READYing process
698 */
699 void setPukEntryProgressDialog(ProgressDialog dialog) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700700 Log.i(LOG_TAG, "setPukEntryProgressDialog - set to "
701 + (dialog == null ? "null" : "activity"));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700702 mPUKEntryProgressDialog = dialog;
703 }
704
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700705 KeyguardManager getKeyguardManager() {
706 return mKeyguardManager;
707 }
708
709 private void onMMIComplete(AsyncResult r) {
710 if (VDBG) Log.d(LOG_TAG, "onMMIComplete()...");
711 MmiCode mmiCode = (MmiCode) r.result;
Stuart Scottdcf40a92014-12-09 10:45:01 -0800712 PhoneUtils.displayMMIComplete(mmiCode.getPhone(), getInstance(), mmiCode, null, null);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700713 }
714
fionaxu80126972017-02-01 17:01:26 -0800715 private void initForNewRadioTechnology() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700716 if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology...");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700717 notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700718 }
719
Taesu Lee62f826d2020-08-10 16:01:18 +0900720 private void handleAirplaneModeChange(boolean isAirplaneNewlyOn) {
721 int cellState =
722 Settings.Global.getInt(
723 getContentResolver(), Settings.Global.CELL_ON, PhoneConstants.CELL_ON_FLAG);
Chris Mantona09f3632016-02-09 14:48:42 -0800724 switch (cellState) {
725 case PhoneConstants.CELL_OFF_FLAG:
726 // Airplane mode does not affect the cell radio if user
727 // has turned it off.
728 break;
729 case PhoneConstants.CELL_ON_FLAG:
Taesu Lee62f826d2020-08-10 16:01:18 +0900730 maybeTurnCellOff(isAirplaneNewlyOn);
Chris Mantona09f3632016-02-09 14:48:42 -0800731 break;
732 case PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG:
Taesu Lee62f826d2020-08-10 16:01:18 +0900733 maybeTurnCellOn(isAirplaneNewlyOn);
Chris Mantona09f3632016-02-09 14:48:42 -0800734 break;
735 }
Hall Liu7f56e1a2019-07-10 14:41:14 -0700736 for (Phone phone : PhoneFactory.getPhones()) {
737 phone.getServiceStateTracker().onAirplaneModeChanged(isAirplaneNewlyOn);
738 }
Chris Mantona09f3632016-02-09 14:48:42 -0800739 }
740
741 /*
742 * Returns true if the radio must be turned off when entering airplane mode.
743 */
Taesu Lee62f826d2020-08-10 16:01:18 +0900744 private boolean isCellOffInAirplaneMode() {
745 String airplaneModeRadios =
746 Settings.Global.getString(
747 getContentResolver(), Settings.Global.AIRPLANE_MODE_RADIOS);
Chris Mantona09f3632016-02-09 14:48:42 -0800748 return airplaneModeRadios == null
749 || airplaneModeRadios.contains(Settings.Global.RADIO_CELL);
750 }
751
Taesu Lee62f826d2020-08-10 16:01:18 +0900752 private void setRadioPowerOff() {
Chris Mantona09f3632016-02-09 14:48:42 -0800753 Log.i(LOG_TAG, "Turning radio off - airplane");
Taesu Lee62f826d2020-08-10 16:01:18 +0900754 Settings.Global.putInt(
755 getContentResolver(),
756 Settings.Global.CELL_ON,
757 PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG);
Chris Mantona09f3632016-02-09 14:48:42 -0800758 Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT, 0);
Taesu Lee62f826d2020-08-10 16:01:18 +0900759 TelephonyProperties.airplane_mode_on(true); // true means int value 1
Chris Mantona09f3632016-02-09 14:48:42 -0800760 PhoneUtils.setRadioPower(false);
Ling Ma317906d2022-12-05 15:58:14 -0800761 clearCacheOnRadioOff();
762 }
763
764 /** Clear fields on power off radio **/
765 private void clearCacheOnRadioOff() {
766 // Re-show is-roaming notifications after APM mode
767 mPrevRoamingOperatorNumerics.clear();
Chris Mantona09f3632016-02-09 14:48:42 -0800768 }
769
Taesu Lee62f826d2020-08-10 16:01:18 +0900770 private void setRadioPowerOn() {
Chris Mantona09f3632016-02-09 14:48:42 -0800771 Log.i(LOG_TAG, "Turning radio on - airplane");
Taesu Lee62f826d2020-08-10 16:01:18 +0900772 Settings.Global.putInt(
773 getContentResolver(), Settings.Global.CELL_ON, PhoneConstants.CELL_ON_FLAG);
774 Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT, 1);
Meng Wang61307622019-10-23 14:08:43 -0700775 TelephonyProperties.airplane_mode_on(false); // false means int value 0
Chris Mantona09f3632016-02-09 14:48:42 -0800776 PhoneUtils.setRadioPower(true);
777 }
778
Taesu Lee62f826d2020-08-10 16:01:18 +0900779 private void maybeTurnCellOff(boolean isAirplaneNewlyOn) {
Chris Mantona09f3632016-02-09 14:48:42 -0800780 if (isAirplaneNewlyOn) {
Santos Cordone18902f2016-03-22 17:16:04 -0700781 // If we are trying to turn off the radio, make sure there are no active
782 // emergency calls. If there are, switch airplane mode back to off.
Taesu Lee62f826d2020-08-10 16:01:18 +0900783 TelecomManager tm = (TelecomManager) getSystemService(TELECOM_SERVICE);
Tyler Gunn900d8fd2018-09-21 09:22:12 -0700784
785 if (tm != null && tm.isInEmergencyCall()) {
Santos Cordone18902f2016-03-22 17:16:04 -0700786 // Switch airplane mode back to off.
Jordan Liu0e819b12019-08-28 15:33:05 -0700787 ConnectivityManager cm =
Taesu Lee62f826d2020-08-10 16:01:18 +0900788 (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
Jordan Liu0e819b12019-08-28 15:33:05 -0700789 cm.setAirplaneMode(false);
Santos Cordone18902f2016-03-22 17:16:04 -0700790 Toast.makeText(this, R.string.radio_off_during_emergency_call, Toast.LENGTH_LONG)
791 .show();
792 Log.i(LOG_TAG, "Ignoring airplane mode: emergency call. Turning airplane off");
Taesu Lee62f826d2020-08-10 16:01:18 +0900793 } else if (isCellOffInAirplaneMode()) {
794 setRadioPowerOff();
Santos Cordone18902f2016-03-22 17:16:04 -0700795 } else {
Chris Mantona09f3632016-02-09 14:48:42 -0800796 Log.i(LOG_TAG, "Ignoring airplane mode: settings prevent cell radio power off");
Santos Cordone18902f2016-03-22 17:16:04 -0700797 }
Chris Mantona09f3632016-02-09 14:48:42 -0800798 }
799 }
800
Taesu Lee62f826d2020-08-10 16:01:18 +0900801 private void maybeTurnCellOn(boolean isAirplaneNewlyOn) {
Chris Mantona09f3632016-02-09 14:48:42 -0800802 if (!isAirplaneNewlyOn) {
Taesu Lee62f826d2020-08-10 16:01:18 +0900803 setRadioPowerOn();
Santos Cordone18902f2016-03-22 17:16:04 -0700804 }
805 }
806
Santos Cordon593ab382013-08-06 21:58:23 -0700807 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700808 * Receiver for misc intent broadcasts the Phone app cares about.
809 */
810 private class PhoneAppBroadcastReceiver extends BroadcastReceiver {
811 @Override
812 public void onReceive(Context context, Intent intent) {
813 String action = intent.getAction();
814 if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
Taesu Lee3dc572b2020-08-07 18:16:22 +0900815 boolean airplaneMode = intent.getBooleanExtra("state", false);
Taesu Lee62f826d2020-08-10 16:01:18 +0900816 handleAirplaneModeChange(airplaneMode);
Amit Mahajanf5d92c82018-11-02 17:44:40 -0700817 } else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
818 // re-register as it may be a new IccCard
819 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY,
820 SubscriptionManager.INVALID_PHONE_INDEX);
821 if (SubscriptionManager.isValidPhoneId(phoneId)) {
822 PhoneUtils.unregisterIccStatus(mHandler, phoneId);
823 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED, phoneId);
824 }
Nazish Tabassum160d2112019-12-23 17:31:33 +0530825 String iccStatus = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
826 mHandler.sendMessage(mHandler.obtainMessage(EVENT_SIM_STATE_CHANGED,
827 new EventSimStateChangedBag(phoneId, iccStatus)));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700828 } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) {
829 String newPhone = intent.getStringExtra(PhoneConstants.PHONE_NAME_KEY);
fionaxu80126972017-02-01 17:01:26 -0800830 Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active.");
831 initForNewRadioTechnology();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700832 } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530833 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY, 0);
Srikanth Chintala079912a2016-03-03 16:35:01 +0530834 phoneInEcm = PhoneFactory.getPhone(phoneId);
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530835 Log.d(LOG_TAG, "Emergency Callback Mode. phoneId:" + phoneId);
836 if (phoneInEcm != null) {
837 if (TelephonyCapabilities.supportsEcm(phoneInEcm)) {
838 Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp.");
839 // Start Emergency Callback Mode service
Daniel Bright30efde42020-01-09 22:11:15 -0800840 if (intent.getBooleanExtra(
841 TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, false)) {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530842 context.startService(new Intent(context,
843 EmergencyCallbackModeService.class));
844 } else {
845 phoneInEcm = null;
846 }
847 } else {
848 // It doesn't make sense to get ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
849 // on a device that doesn't support ECM in the first place.
850 Log.e(LOG_TAG, "Got ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, but "
851 + "ECM isn't supported for phone: " + phoneInEcm.getPhoneName());
852 phoneInEcm = null;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700853 }
854 } else {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530855 Log.w(LOG_TAG, "phoneInEcm is null.");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700856 }
Jack Yu1a2fc352017-07-14 17:14:37 -0700857 } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) {
858 // Roaming status could be overridden by carrier config, so we need to update it.
859 if (VDBG) Log.v(LOG_TAG, "carrier config changed.");
860 updateDataRoamingStatus();
chen xubaf9fe52019-07-02 17:28:24 -0700861 updateLimitedSimFunctionForDualSim();
Lei Liu863eac02020-06-24 20:12:55 +0800862 int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
863 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
864 if (SubscriptionManager.isValidSubscriptionId(subId)) {
865 mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARRIER_CONFIG_CHANGED,
866 new Integer(subId)));
867 }
Jack Yu1a2fc352017-07-14 17:14:37 -0700868 } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
869 // We also need to pay attention when default data subscription changes.
870 if (VDBG) Log.v(LOG_TAG, "default data sub changed.");
871 mDefaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
872 registerSettingsObserver();
873 Phone phone = getPhone(mDefaultDataSubId);
874 if (phone != null) {
875 updateDataRoamingStatus();
876 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700877 }
878 }
879 }
880
Sarah Chin072ffb22022-05-03 17:58:59 -0700881 private void handleServiceStateChanged(ServiceState serviceState, int subId) {
Jack Yu1a2fc352017-07-14 17:14:37 -0700882 if (VDBG) Log.v(LOG_TAG, "handleServiceStateChanged");
Sarah Chin072ffb22022-05-03 17:58:59 -0700883 int state = serviceState.getState();
884 notificationMgr.updateNetworkSelection(state, subId);
Jack Yu1a2fc352017-07-14 17:14:37 -0700885
Sarah Chin072ffb22022-05-03 17:58:59 -0700886 if (VDBG) {
887 Log.v(LOG_TAG, "subId=" + subId + ", mDefaultDataSubId="
888 + mDefaultDataSubId + ", ss roaming=" + serviceState.getDataRoaming());
889 }
890 if (subId == mDefaultDataSubId) {
Ling Ma317906d2022-12-05 15:58:14 -0800891 updateDataRoamingStatus(serviceState.getOperatorNumeric());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700892 }
893 }
894
Jack Yu1a2fc352017-07-14 17:14:37 -0700895 /**
896 * When roaming, if mobile data cannot be established due to data roaming not enabled, we need
897 * to notify the user so they can enable it through settings. Vise versa if the condition
898 * changes, we need to dismiss the notification.
899 */
900 private void updateDataRoamingStatus() {
Ling Ma317906d2022-12-05 15:58:14 -0800901 updateDataRoamingStatus(null /*roamingOperatorNumeric*/);
902 }
903
904 /**
905 * When roaming, if mobile data cannot be established due to data roaming not enabled, we need
906 * to notify the user so they can enable it through settings. Vise versa if the condition
907 * changes, we need to dismiss the notification.
908 * @param roamingOperatorNumeric The operator numeric for the current roaming. {@code null} if
909 * the current roaming operator numeric didn't change.
910 */
911 private void updateDataRoamingStatus(@Nullable String roamingOperatorNumeric) {
Jack Yu1a2fc352017-07-14 17:14:37 -0700912 if (VDBG) Log.v(LOG_TAG, "updateDataRoamingStatus");
913 Phone phone = getPhone(mDefaultDataSubId);
914 if (phone == null) {
915 Log.w(LOG_TAG, "Can't get phone with sub id = " + mDefaultDataSubId);
916 return;
917 }
918
Jack Yu3e2ac6e2022-03-26 13:59:45 -0700919 boolean dataAllowed;
920 boolean notAllowedDueToRoamingOff;
Sarah Chine04784a2022-10-31 20:32:34 -0700921 List<DataDisallowedReason> reasons = phone.getDataNetworkController()
922 .getInternetDataDisallowedReasons();
Jack Yu7968c6d2022-07-31 00:43:21 -0700923 dataAllowed = reasons.isEmpty();
924 notAllowedDueToRoamingOff = (reasons.size() == 1
925 && reasons.contains(DataDisallowedReason.ROAMING_DISABLED));
Ling Ma317906d2022-12-05 15:58:14 -0800926 mDataRoamingNotifLog.log("dataAllowed=" + dataAllowed + ", reasons=" + reasons
927 + ", roamingOperatorNumeric=" + roamingOperatorNumeric);
928 if (VDBG) {
929 Log.v(LOG_TAG, "dataAllowed=" + dataAllowed + ", reasons=" + reasons
930 + ", roamingOperatorNumeric=" + roamingOperatorNumeric);
931 }
Jack Yu3e2ac6e2022-03-26 13:59:45 -0700932
933 if (!dataAllowed && notAllowedDueToRoamingOff) {
Ling Ma4e15c322022-12-07 11:20:53 -0800934 // Don't show roaming notification if we've already shown for this MccMnc
935 if (roamingOperatorNumeric != null
936 && !mPrevRoamingOperatorNumerics.add(roamingOperatorNumeric)) {
937 Log.d(LOG_TAG, "Skip roaming disconnected notification since already shown in "
938 + "MccMnc " + roamingOperatorNumeric);
939 return;
940 }
Jordan Liuff2ccd72019-07-23 15:54:41 -0700941 // No need to show it again if we never cancelled it explicitly.
942 if (mPrevRoamingNotification == ROAMING_NOTIFICATION_DISCONNECTED) return;
Jack Yu1a2fc352017-07-14 17:14:37 -0700943 // If the only reason of no data is data roaming disabled, then we notify the user
944 // so the user can turn on data roaming.
Jordan Liuff2ccd72019-07-23 15:54:41 -0700945 mPrevRoamingNotification = ROAMING_NOTIFICATION_DISCONNECTED;
Jack Yu1a2fc352017-07-14 17:14:37 -0700946 Log.d(LOG_TAG, "Show roaming disconnected notification");
Jordan Liuff2ccd72019-07-23 15:54:41 -0700947 mDataRoamingNotifLog.log("Show roaming off.");
Pengquan Meng8783d932017-10-16 14:57:40 -0700948 Message msg = mHandler.obtainMessage(EVENT_DATA_ROAMING_DISCONNECTED);
949 msg.arg1 = mDefaultDataSubId;
950 msg.sendToTarget();
Ling Ma317906d2022-12-05 15:58:14 -0800951 } else if (dataAllowed && dataIsNowRoaming(mDefaultDataSubId)) {
Ling Ma4e15c322022-12-07 11:20:53 -0800952 boolean isShowRoamingNotificationEnabled = getCarrierConfigForSubId(mDefaultDataSubId)
953 .getBoolean(CarrierConfigManager
954 .KEY_SHOW_DATA_CONNECTED_ROAMING_NOTIFICATION_BOOL);
955 if (!isShowRoamingNotificationEnabled) return;
956 // Don't show roaming notification if we've already shown for this MccMnc
957 if (roamingOperatorNumeric != null
958 && !mPrevRoamingOperatorNumerics.add(roamingOperatorNumeric)) {
959 Log.d(LOG_TAG, "Skip roaming connected notification since already shown in "
960 + "MccMnc " + roamingOperatorNumeric);
961 return;
962 }
Jordan Liuff2ccd72019-07-23 15:54:41 -0700963 // No need to show it again if we never cancelled it explicitly, or carrier config
964 // indicates this is not needed.
965 if (mPrevRoamingNotification == ROAMING_NOTIFICATION_CONNECTED) return;
966 mPrevRoamingNotification = ROAMING_NOTIFICATION_CONNECTED;
967 Log.d(LOG_TAG, "Show roaming connected notification");
968 mDataRoamingNotifLog.log("Show roaming on.");
969 Message msg = mHandler.obtainMessage(EVENT_DATA_ROAMING_CONNECTED);
970 msg.arg1 = mDefaultDataSubId;
971 msg.sendToTarget();
972 } else if (mPrevRoamingNotification != ROAMING_NOTIFICATION_NO_NOTIFICATION) {
973 // Otherwise we either 1) we are not roaming or 2) roaming is off but ROAMING_DISABLED
974 // is not the only data disable reason. In this case we dismiss the notification we
975 // showed earlier.
976 mPrevRoamingNotification = ROAMING_NOTIFICATION_NO_NOTIFICATION;
977 Log.d(LOG_TAG, "Dismiss roaming notification");
Jack Yu3e2ac6e2022-03-26 13:59:45 -0700978 mDataRoamingNotifLog.log("Hide. data allowed=" + dataAllowed);
Jack Yu1a2fc352017-07-14 17:14:37 -0700979 mHandler.sendEmptyMessage(EVENT_DATA_ROAMING_OK);
980 }
981 }
982
Jordan Liuff2ccd72019-07-23 15:54:41 -0700983 /**
984 *
985 * @param subId to check roaming on
986 * @return whether we have transitioned to dataRoaming
987 */
988 private boolean dataIsNowRoaming(int subId) {
Sarah Chine04784a2022-10-31 20:32:34 -0700989 return getPhone(subId).getServiceState().getDataRoaming();
Jordan Liuff2ccd72019-07-23 15:54:41 -0700990 }
991
chen xubaf9fe52019-07-02 17:28:24 -0700992 private void updateLimitedSimFunctionForDualSim() {
993 if (DBG) Log.d(LOG_TAG, "updateLimitedSimFunctionForDualSim");
994 // check conditions to display limited SIM function notification under dual SIM
995 SubscriptionManager subMgr = (SubscriptionManager) getSystemService(
996 Context.TELEPHONY_SUBSCRIPTION_SERVICE);
997 List<SubscriptionInfo> subList = subMgr.getActiveSubscriptionInfoList(false);
998 if (subList != null && subList.size() > 1) {
999 CarrierConfigManager configMgr = (CarrierConfigManager)
1000 getSystemService(Context.CARRIER_CONFIG_SERVICE);
1001 for (SubscriptionInfo info : subList) {
1002 PersistableBundle b = configMgr.getConfigForSubId(info.getSubscriptionId());
1003 if (b != null) {
1004 if (b.getBoolean(CarrierConfigManager
1005 .KEY_LIMITED_SIM_FUNCTION_NOTIFICATION_FOR_DSDS_BOOL)) {
1006 notificationMgr.showLimitedSimFunctionWarningNotification(
1007 info.getSubscriptionId(),
1008 info.getDisplayName().toString());
1009 } else {
1010 notificationMgr.dismissLimitedSimFunctionWarningNotification(
1011 info.getSubscriptionId());
1012 }
1013 }
1014 }
1015 } else {
1016 // cancel notifications for all subs
1017 notificationMgr.dismissLimitedSimFunctionWarningNotification(
1018 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
1019 }
1020 notificationMgr.dismissLimitedSimFunctionWarningNotificationForInactiveSubs();
1021
1022 }
1023
Sandeep Kuntade73a6a2014-10-15 18:45:56 +05301024 public Phone getPhoneInEcm() {
1025 return phoneInEcm;
1026 }
1027
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001028 /**
Tyler Gunn9c1071f2014-12-09 10:07:54 -08001029 * Triggers a refresh of the message waiting (voicemail) indicator.
1030 *
1031 * @param subId the subscription id we should refresh the notification for.
1032 */
1033 public void refreshMwiIndicator(int subId) {
1034 notificationMgr.refreshMwi(subId);
1035 }
1036
1037 /**
Pengquan Mengdd9ac822018-09-20 15:25:35 -07001038 * Called when the network selection on the subscription {@code subId} is changed by the user.
1039 *
1040 * @param subId the subscription id.
1041 */
1042 public void onNetworkSelectionChanged(int subId) {
1043 Phone phone = getPhone(subId);
1044 if (phone != null) {
1045 notificationMgr.updateNetworkSelection(phone.getServiceState().getState(), subId);
1046 } else {
1047 Log.w(LOG_TAG, "onNetworkSelectionChanged on null phone, subId: " + subId);
1048 }
1049 }
1050
1051 /**
James.cf Lin4b784aa2021-01-31 03:25:15 +08001052 * @return whether the device supports RCS User Capability Exchange or not.
1053 */
1054 public boolean getDeviceUceEnabled() {
1055 return (mTelephonyRcsService == null) ? false : mTelephonyRcsService.isDeviceUceEnabled();
1056 }
1057
1058 /**
1059 * Set the device supports RCS User Capability Exchange.
1060 * @param isEnabled true if the device supports UCE.
1061 */
1062 public void setDeviceUceEnabled(boolean isEnabled) {
1063 if (mTelephonyRcsService != null) {
1064 mTelephonyRcsService.setDeviceUceEnabled(isEnabled);
1065 }
1066 }
1067
1068 /**
Jack Yu1a2fc352017-07-14 17:14:37 -07001069 * Dump the state of the object, add calls to other objects as desired.
1070 *
1071 * @param fd File descriptor
1072 * @param printWriter Print writer
1073 * @param args Arguments
1074 */
1075 public void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) {
1076 IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " ");
1077 pw.println("------- PhoneGlobals -------");
1078 pw.increaseIndent();
Jordan Liuff2ccd72019-07-23 15:54:41 -07001079 pw.println("mPrevRoamingNotification=" + mPrevRoamingNotification);
Jack Yu1a2fc352017-07-14 17:14:37 -07001080 pw.println("mDefaultDataSubId=" + mDefaultDataSubId);
1081 pw.println("mDataRoamingNotifLog:");
Keun young Parkdebb8532019-05-30 16:35:27 -07001082 pw.println("isSmsCapable=" + TelephonyManager.from(this).isSmsCapable());
Jack Yu1a2fc352017-07-14 17:14:37 -07001083 pw.increaseIndent();
1084 mDataRoamingNotifLog.dump(fd, pw, args);
1085 pw.decreaseIndent();
Brad Ebinger05f52c22019-12-05 13:03:21 -08001086 pw.println("ImsResolver:");
1087 pw.increaseIndent();
1088 try {
Brad Ebingerd1947d82021-05-17 20:54:49 +00001089 if (ImsResolver.getInstance() != null) ImsResolver.getInstance().dump(fd, pw, args);
Brad Ebinger05f52c22019-12-05 13:03:21 -08001090 } catch (Exception e) {
1091 e.printStackTrace();
1092 }
1093 pw.decreaseIndent();
Brad Ebingera68a4972020-01-30 17:31:23 -08001094 pw.println("RcsService:");
1095 try {
1096 if (mTelephonyRcsService != null) mTelephonyRcsService.dump(fd, pw, args);
1097 } catch (Exception e) {
1098 e.printStackTrace();
1099 }
Hunsuk Choi89bd22c2021-11-01 13:04:54 +00001100 pw.println("ImsStateCallbackController:");
1101 try {
1102 if (mImsStateCallbackController != null) mImsStateCallbackController.dump(pw);
1103 } catch (Exception e) {
1104 e.printStackTrace();
1105 }
Hwangoo Parkba21cf22022-11-30 14:34:04 +00001106 pw.println("DomainSelectionResolver:");
1107 pw.increaseIndent();
1108 try {
1109 if (DomainSelectionResolver.getInstance() != null) {
1110 DomainSelectionResolver.getInstance().dump(fd, pw, args);
1111 }
1112 } catch (Exception e) {
1113 e.printStackTrace();
1114 }
1115 pw.decreaseIndent();
1116 if (mDomainSelectionService != null) {
1117 mDomainSelectionService.dump(fd, pw, args);
1118 }
Jack Yu1a2fc352017-07-14 17:14:37 -07001119 pw.decreaseIndent();
Ling Ma317906d2022-12-05 15:58:14 -08001120 pw.println("mPrevRoamingOperatorNumerics:" + mPrevRoamingOperatorNumerics);
Jack Yu1a2fc352017-07-14 17:14:37 -07001121 pw.println("------- End PhoneGlobals -------");
1122 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001123}