blob: 96929bf7b863a5479d070835a2526124a05778d5 [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;
Daniel Bantab26e96f2022-10-19 23:25:35 +000073import com.android.internal.telephony.emergency.EmergencyStateTracker;
Brad Ebinger05f52c22019-12-05 13:03:21 -080074import com.android.internal.telephony.ims.ImsResolver;
Tyler Gunn92479152021-01-20 16:30:10 -080075import com.android.internal.telephony.imsphone.ImsPhone;
76import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
Aishwarya Mallampati481aeee2023-02-17 21:32:22 +000077import com.android.internal.telephony.satellite.SatelliteController;
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +000078import com.android.internal.telephony.uicc.UiccPort;
Jordan Liu06bdef12021-03-24 17:25:46 -070079import com.android.internal.telephony.uicc.UiccProfile;
Jack Yu1a2fc352017-07-14 17:14:37 -070080import com.android.internal.util.IndentingPrintWriter;
Andrew Leefb7f92e2015-02-26 16:23:32 -080081import com.android.phone.settings.SettingsConstants;
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -070082import com.android.phone.vvm.CarrierVvmPackageInstalledReceiver;
Hwangoo Parkba21cf22022-11-30 14:34:04 +000083import com.android.services.telephony.domainselection.TelephonyDomainSelectionService;
James.cf Linc9f35a42020-01-15 02:35:22 +080084import com.android.services.telephony.rcs.TelephonyRcsService;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070085
Jack Yu1a2fc352017-07-14 17:14:37 -070086import java.io.FileDescriptor;
87import java.io.PrintWriter;
Jordan Liuff2ccd72019-07-23 15:54:41 -070088import java.lang.annotation.Retention;
89import java.lang.annotation.RetentionPolicy;
chen xubaf9fe52019-07-02 17:28:24 -070090import java.util.List;
Jack Yu1a2fc352017-07-14 17:14:37 -070091
Santos Cordon7d4ddf62013-07-10 11:58:08 -070092/**
93 * Global state for the telephony subsystem when running in the primary
94 * phone process.
95 */
Sailesh Nepalbf900542014-07-15 16:18:32 -070096public class PhoneGlobals extends ContextWrapper {
Jack Yu1a2fc352017-07-14 17:14:37 -070097 public static final String LOG_TAG = "PhoneGlobals";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070098
99 /**
100 * Phone app-wide debug level:
101 * 0 - no debug logging
102 * 1 - normal debug logging if ro.debuggable is set (which is true in
103 * "eng" and "userdebug" builds but not "user" builds)
104 * 2 - ultra-verbose debug logging
105 *
106 * Most individual classes in the phone app have a local DBG constant,
107 * typically set to
108 * (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1)
109 * or else
110 * (PhoneApp.DBG_LEVEL >= 2)
111 * depending on the desired verbosity.
112 *
113 * ***** DO NOT SUBMIT WITH DBG_LEVEL > 0 *************
114 */
Andrew Lee88b51e22014-10-29 15:48:51 -0700115 public static final int DBG_LEVEL = 0;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700116
117 private static final boolean DBG =
118 (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
119 private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
120
121 // Message codes; see mHandler below.
122 private static final int EVENT_SIM_NETWORK_LOCKED = 3;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700123 private static final int EVENT_SIM_STATE_CHANGED = 8;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700124 private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10;
Jordan Liuff2ccd72019-07-23 15:54:41 -0700125 private static final int EVENT_DATA_ROAMING_CONNECTED = 11;
126 private static final int EVENT_DATA_ROAMING_OK = 12;
127 private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 13;
Jordan Liuff2ccd72019-07-23 15:54:41 -0700128 private static final int EVENT_DATA_ROAMING_SETTINGS_CHANGED = 15;
129 private static final int EVENT_MOBILE_DATA_SETTINGS_CHANGED = 16;
Lei Liu863eac02020-06-24 20:12:55 +0800130 private static final int EVENT_CARRIER_CONFIG_CHANGED = 17;
Sarah Chin072ffb22022-05-03 17:58:59 -0700131 private static final int EVENT_MULTI_SIM_CONFIG_CHANGED = 18;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700132
133 // The MMI codes are also used by the InCallScreen.
134 public static final int MMI_INITIATE = 51;
135 public static final int MMI_COMPLETE = 52;
136 public static final int MMI_CANCEL = 53;
137 // Don't use message codes larger than 99 here; those are reserved for
138 // the individual Activities of the Phone UI.
139
Santos Cordone18902f2016-03-22 17:16:04 -0700140 public static final int AIRPLANE_ON = 1;
141 public static final int AIRPLANE_OFF = 0;
142
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700143 /**
144 * Allowable values for the wake lock code.
145 * SLEEP means the device can be put to sleep.
146 * PARTIAL means wake the processor, but we display can be kept off.
147 * FULL means wake both the processor and the display.
148 */
149 public enum WakeState {
150 SLEEP,
151 PARTIAL,
152 FULL
153 }
154
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700155 private static PhoneGlobals sMe;
156
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700157 CallManager mCM;
Santos Cordon63a84242013-07-23 13:32:52 -0700158 CallNotifier notifier;
Santos Cordon63a84242013-07-23 13:32:52 -0700159 NotificationMgr notificationMgr;
James.cf Linc9f35a42020-01-15 02:35:22 +0800160 TelephonyRcsService mTelephonyRcsService;
Andrew Lee9431b832015-03-09 18:46:45 -0700161 public PhoneInterfaceManager phoneMgr;
James.cf Linaf3183c2019-10-24 00:59:00 +0800162 public ImsRcsController imsRcsController;
Hunsuk Choi3b742d62021-10-25 19:48:34 +0000163 public ImsStateCallbackController mImsStateCallbackController;
joonhunshincffb7fc2021-11-28 07:32:01 +0000164 public ImsProvisioningController mImsProvisioningController;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800165 CarrierConfigLoader configLoader;
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000166 TelephonyDomainSelectionService mDomainSelectionService;
Santos Cordon63a84242013-07-23 13:32:52 -0700167
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530168 private Phone phoneInEcm;
Santos Cordon63a84242013-07-23 13:32:52 -0700169
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700170 static boolean sVoiceCapable = true;
171
Santos Cordonc593d002015-06-03 15:41:15 -0700172 // TODO: Remove, no longer used.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700173 CdmaPhoneCallState cdmaPhoneCallState;
174
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700175 // The currently-active PUK entry activity and progress dialog.
176 // Normally, these are the Emergency Dialer and the subsequent
177 // progress dialog. null if there is are no such objects in
178 // the foreground.
179 private Activity mPUKEntryActivity;
180 private ProgressDialog mPUKEntryProgressDialog;
181
Jordan Liuff2ccd72019-07-23 15:54:41 -0700182 /** @hide */
183 @Retention(RetentionPolicy.SOURCE)
184 @IntDef(prefix = {"ROAMING_NOTIFICATION_"},
185 value = {
186 ROAMING_NOTIFICATION_NO_NOTIFICATION,
187 ROAMING_NOTIFICATION_CONNECTED,
188 ROAMING_NOTIFICATION_DISCONNECTED})
189 public @interface RoamingNotification {}
190
191 private static final int ROAMING_NOTIFICATION_NO_NOTIFICATION = 0;
192 private static final int ROAMING_NOTIFICATION_CONNECTED = 1;
193 private static final int ROAMING_NOTIFICATION_DISCONNECTED = 2;
194
195 @RoamingNotification
196 private int mPrevRoamingNotification = ROAMING_NOTIFICATION_NO_NOTIFICATION;
Jack Yu953f9352017-05-18 14:41:06 -0700197
Ling Ma317906d2022-12-05 15:58:14 -0800198 /** Operator numerics for which we've shown is-roaming notifications. **/
199 private ArraySet<String> mPrevRoamingOperatorNumerics = new ArraySet<>();
200
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700201 private WakeState mWakeState = WakeState.SLEEP;
202
203 private PowerManager mPowerManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700204 private PowerManager.WakeLock mWakeLock;
205 private PowerManager.WakeLock mPartialWakeLock;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700206 private KeyguardManager mKeyguardManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700207
Jack Yu1a2fc352017-07-14 17:14:37 -0700208 private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
209 private final LocalLog mDataRoamingNotifLog = new LocalLog(50);
210
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700211 // Broadcast receiver for various intent broadcasts (see onCreate())
212 private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver();
213
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -0700214 private final CarrierVvmPackageInstalledReceiver mCarrierVvmPackageInstalledReceiver =
215 new CarrierVvmPackageInstalledReceiver();
216
Jack Yu1a2fc352017-07-14 17:14:37 -0700217 private final SettingsObserver mSettingsObserver;
Siim Sammul182d61b2021-05-04 16:01:42 +0100218 private BinderCallsStats.SettingsObserver mBinderCallsSettingsObserver;
Jack Yu1a2fc352017-07-14 17:14:37 -0700219
Sarah Chin072ffb22022-05-03 17:58:59 -0700220 // Mapping of phone ID to the associated TelephonyCallback. These should be registered without
221 // fine or coarse location since we only use ServiceState for
222 private PhoneAppCallback[] mTelephonyCallbacks;
223
224 private class PhoneAppCallback extends TelephonyCallback implements
225 TelephonyCallback.ServiceStateListener {
226 private final int mSubId;
227
228 PhoneAppCallback(int subId) {
229 mSubId = subId;
230 }
231
232 @Override
233 public void onServiceStateChanged(ServiceState serviceState) {
234 // Note when registering that we should be registering with INCLUDE_LOCATION_DATA_NONE.
235 // PhoneGlobals only uses the state and roaming status, which does not require location.
236 handleServiceStateChanged(serviceState, mSubId);
237 }
238
239 public int getSubId() {
240 return mSubId;
241 }
242 }
243
Nazish Tabassum160d2112019-12-23 17:31:33 +0530244 private static class EventSimStateChangedBag {
245 final int mPhoneId;
246 final String mIccStatus;
247
248 EventSimStateChangedBag(int phoneId, String iccStatus) {
249 mPhoneId = phoneId;
250 mIccStatus = iccStatus;
251 }
252 }
253
Jordan Liu06bdef12021-03-24 17:25:46 -0700254 // Some carrier config settings disable the network lock screen, so we call handleSimLock
255 // when either SIM_LOCK or CARRIER_CONFIG changes so that no matter which one happens first,
256 // we still do the right thing
257 private void handleSimLock(int subType, Phone phone) {
258 PersistableBundle cc = getCarrierConfigForSubId(phone.getSubId());
259 if (!CarrierConfigManager.isConfigForIdentifiedCarrier(cc)) {
260 // If we only have the default carrier config just return, to avoid popping up the
261 // the SIM lock screen when it's disabled by the carrier.
262 Log.i(LOG_TAG, "Not showing 'SIM network unlock' screen. Carrier config not loaded");
263 return;
264 }
265 if (cc.getBoolean(CarrierConfigManager.KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL)) {
266 // Some products don't have the concept of a "SIM network lock"
267 Log.i(LOG_TAG, "Not showing 'SIM network unlock' screen. Disabled by carrier config");
268 return;
269 }
270
271 // if passed in subType is unknown, retrieve it here.
272 if (subType == -1) {
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +0000273 final UiccPort uiccPort = phone.getUiccPort();
274 if (uiccPort == null) {
Jordan Liu06bdef12021-03-24 17:25:46 -0700275 Log.e(LOG_TAG,
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +0000276 "handleSimLock: uiccPort for phone " + phone.getPhoneId() + " is null");
Jordan Liu06bdef12021-03-24 17:25:46 -0700277 return;
278 }
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +0000279 final UiccProfile uiccProfile = uiccPort.getUiccProfile();
Jordan Liu06bdef12021-03-24 17:25:46 -0700280 if (uiccProfile == null) {
281 Log.e(LOG_TAG,
282 "handleSimLock: uiccProfile for phone " + phone.getPhoneId() + " is null");
283 return;
284 }
285 subType = uiccProfile.getApplication(
286 uiccProfile.mCurrentAppType).getPersoSubState().ordinal();
287 }
288 // Normal case: show the "SIM network unlock" PIN entry screen.
289 // The user won't be able to do anything else until
290 // they enter a valid SIM network PIN.
291 Log.i(LOG_TAG, "show sim depersonal panel");
292 IccNetworkDepersonalizationPanel.showDialog(phone, subType);
293 }
294
295 private boolean isSimLocked(Phone phone) {
296 TelephonyManager tm = getSystemService(TelephonyManager.class);
297 return tm.createForSubscriptionId(phone.getSubId()).getSimState()
298 == TelephonyManager.SIM_STATE_NETWORK_LOCKED;
299 }
300
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700301 Handler mHandler = new Handler() {
302 @Override
303 public void handleMessage(Message msg) {
304 PhoneConstants.State phoneState;
Jack Yu1a2fc352017-07-14 17:14:37 -0700305 if (VDBG) Log.v(LOG_TAG, "event=" + msg.what);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700306 switch (msg.what) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700307 // TODO: This event should be handled by the lock screen, just
308 // like the "SIM missing" and "Sim locked" cases (bug 1804111).
309 case EVENT_SIM_NETWORK_LOCKED:
Jordan Liu06bdef12021-03-24 17:25:46 -0700310 int subType = (Integer) ((AsyncResult) msg.obj).result;
311 Phone phone = (Phone) ((AsyncResult) msg.obj).userObj;
312 handleSimLock(subType, phone);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700313 break;
314
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700315 case EVENT_DATA_ROAMING_DISCONNECTED:
Jordan Liuff2ccd72019-07-23 15:54:41 -0700316 notificationMgr.showDataRoamingNotification(msg.arg1, false);
317 break;
318
319 case EVENT_DATA_ROAMING_CONNECTED:
320 notificationMgr.showDataRoamingNotification(msg.arg1, true);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700321 break;
322
323 case EVENT_DATA_ROAMING_OK:
Jordan Liuff2ccd72019-07-23 15:54:41 -0700324 notificationMgr.hideDataRoamingNotification();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700325 break;
326
327 case MMI_COMPLETE:
328 onMMIComplete((AsyncResult) msg.obj);
329 break;
330
331 case MMI_CANCEL:
Stuart Scottdcf40a92014-12-09 10:45:01 -0800332 PhoneUtils.cancelMmiCode(mCM.getFgPhone());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700333 break;
334
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700335 case EVENT_SIM_STATE_CHANGED:
336 // Marks the event where the SIM goes into ready state.
337 // Right now, this is only used for the PUK-unlocking
338 // process.
Nazish Tabassum160d2112019-12-23 17:31:33 +0530339 EventSimStateChangedBag bag = (EventSimStateChangedBag)msg.obj;
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700340 if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(bag.mIccStatus)
Nazish Tabassum59126a92020-07-03 21:44:49 +0530341 || IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(bag.mIccStatus)
342 || IccCardConstants.INTENT_VALUE_ICC_NOT_READY.equals(bag.mIccStatus)
343 || IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(bag.mIccStatus)) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700344 // when the right event is triggered and there
345 // are UI objects in the foreground, we close
346 // them to display the lock panel.
347 if (mPUKEntryActivity != null) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700348 Log.i(LOG_TAG, "Dismiss puk entry activity");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700349 mPUKEntryActivity.finish();
350 mPUKEntryActivity = null;
351 }
352 if (mPUKEntryProgressDialog != null) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700353 Log.i(LOG_TAG, "Dismiss puk progress dialog");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700354 mPUKEntryProgressDialog.dismiss();
355 mPUKEntryProgressDialog = null;
356 }
Nazish Tabassum59126a92020-07-03 21:44:49 +0530357 Log.i(LOG_TAG, "Dismissing depersonal panel" + (bag.mIccStatus));
Nazish Tabassum160d2112019-12-23 17:31:33 +0530358 IccNetworkDepersonalizationPanel.dialogDismiss(bag.mPhoneId);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700359 }
360 break;
361
362 case EVENT_UNSOL_CDMA_INFO_RECORD:
363 //TODO: handle message here;
364 break;
Jack Yu1a2fc352017-07-14 17:14:37 -0700365 case EVENT_DATA_ROAMING_SETTINGS_CHANGED:
366 case EVENT_MOBILE_DATA_SETTINGS_CHANGED:
367 updateDataRoamingStatus();
368 break;
Lei Liu863eac02020-06-24 20:12:55 +0800369 case EVENT_CARRIER_CONFIG_CHANGED:
370 int subId = (Integer) msg.obj;
371 // The voicemail number could be overridden by carrier config, so need to
372 // refresh the message waiting (voicemail) indicator.
373 refreshMwiIndicator(subId);
Jordan Liu06bdef12021-03-24 17:25:46 -0700374 phone = getPhone(subId);
Sarah Chin072ffb22022-05-03 17:58:59 -0700375 if (phone != null) {
376 if (isSimLocked(phone)) {
377 // pass in subType=-1 so handleSimLock can find the actual subType if
378 // needed. This is safe as valid values for subType are >= 0
379 handleSimLock(-1, phone);
380 }
381 TelephonyManager tm = getSystemService(TelephonyManager.class);
382 PhoneAppCallback callback = mTelephonyCallbacks[phone.getPhoneId()];
383 // TODO: We may need to figure out a way to unregister if subId is invalid
384 tm.createForSubscriptionId(callback.getSubId())
385 .unregisterTelephonyCallback(callback);
386 callback = new PhoneAppCallback(subId);
387 tm.createForSubscriptionId(subId).registerTelephonyCallback(
Ling Ma317906d2022-12-05 15:58:14 -0800388 TelephonyManager.INCLUDE_LOCATION_DATA_COARSE, mHandler::post,
Sarah Chin072ffb22022-05-03 17:58:59 -0700389 callback);
390 mTelephonyCallbacks[phone.getPhoneId()] = callback;
391 }
392 break;
393 case EVENT_MULTI_SIM_CONFIG_CHANGED:
394 int activeModems = (int) ((AsyncResult) msg.obj).result;
395 TelephonyManager tm = getSystemService(TelephonyManager.class);
396 // Unregister all previous callbacks
397 for (int phoneId = 0; phoneId < mTelephonyCallbacks.length; phoneId++) {
398 PhoneAppCallback callback = mTelephonyCallbacks[phoneId];
399 if (callback != null) {
400 tm.createForSubscriptionId(callback.getSubId())
401 .unregisterTelephonyCallback(callback);
402 mTelephonyCallbacks[phoneId] = null;
403 }
404 }
405 // Register callbacks for all active modems
406 for (int phoneId = 0; phoneId < activeModems; phoneId++) {
407 int sub = PhoneFactory.getPhone(phoneId).getSubId();
408 PhoneAppCallback callback = new PhoneAppCallback(sub);
409 tm.createForSubscriptionId(sub).registerTelephonyCallback(
410 TelephonyManager.INCLUDE_LOCATION_DATA_NONE, mHandler::post,
411 callback);
412 mTelephonyCallbacks[phoneId] = callback;
Jordan Liu06bdef12021-03-24 17:25:46 -0700413 }
Lei Liu863eac02020-06-24 20:12:55 +0800414 break;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700415 }
416 }
417 };
418
419 public PhoneGlobals(Context context) {
420 super(context);
421 sMe = this;
Jack Yu1a2fc352017-07-14 17:14:37 -0700422 mSettingsObserver = new SettingsObserver(context, mHandler);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700423 }
424
425 public void onCreate() {
426 if (VDBG) Log.v(LOG_TAG, "onCreate()...");
427
428 ContentResolver resolver = getContentResolver();
429
Hall Liuaa4211e2021-01-20 15:43:39 -0800430 // Initialize the shim from frameworks/opt/telephony into packages/services/Telephony.
431 TelephonyLocalConnection.setInstance(new LocalConnectionImpl(this));
432
Sarah Chin072ffb22022-05-03 17:58:59 -0700433 TelephonyManager tm = getSystemService(TelephonyManager.class);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700434 // Cache the "voice capable" flag.
435 // This flag currently comes from a resource (which is
436 // overrideable on a per-product basis):
Sarah Chin072ffb22022-05-03 17:58:59 -0700437 sVoiceCapable = tm.isVoiceCapable();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700438 // ...but this might eventually become a PackageManager "system
439 // feature" instead, in which case we'd do something like:
440 // sVoiceCapable =
441 // getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_VOICE_CALLS);
442
Stuart Scottdcf40a92014-12-09 10:45:01 -0800443 if (mCM == null) {
Nathan Haroldf9df6ea2019-03-08 11:54:22 -0800444 // Initialize AnomalyReporter early so that it can be used
445 AnomalyReporter.initialize(this);
Nathan Harold0db5c5e2019-01-22 20:18:56 -0800446
Youming Ye47a6adc2018-11-19 15:33:36 -0800447 // Inject telephony component factory if configured using other jars.
448 XmlResourceParser parser = getResources().getXml(R.xml.telephony_injection);
449 TelephonyComponentFactory.getInstance().injectTheComponentFactory(parser);
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000450
451 // Create DomainSelectionResolver always, but it MUST be initialized only when
452 // the device supports AOSP domain selection architecture and
453 // has new IRadio that supports its related HAL APIs.
454 DomainSelectionResolver.make(this,
455 getResources().getBoolean(R.bool.config_enable_aosp_domain_selection));
456
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700457 // Initialize the telephony framework
458 PhoneFactory.makeDefaultPhones(this);
459
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000460 // Initialize the DomainSelectionResolver after creating the Phone instance
461 // to check the Radio HAL version.
462 if (DomainSelectionResolver.getInstance().isDomainSelectionSupported()) {
463 mDomainSelectionService = new TelephonyDomainSelectionService(this);
464 DomainSelectionResolver.getInstance().initialize(mDomainSelectionService);
Daniel Bantab26e96f2022-10-19 23:25:35 +0000465 // Initialize EmergencyStateTracker if domain selection is supported
466 boolean isSuplDdsSwitchRequiredForEmergencyCall = getResources()
467 .getBoolean(R.bool.config_gnss_supl_requires_default_data_for_emergency);
468 EmergencyStateTracker.make(this, isSuplDdsSwitchRequiredForEmergencyCall);
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000469 }
470
Brad Ebinger05f52c22019-12-05 13:03:21 -0800471 // Only bring up ImsResolver if the device supports having an IMS stack.
472 if (getPackageManager().hasSystemFeature(
473 PackageManager.FEATURE_TELEPHONY_IMS)) {
474 // Get the package name of the default IMS implementation.
475 String defaultImsMmtelPackage = getResources().getString(
476 R.string.config_ims_mmtel_package);
477 String defaultImsRcsPackage = getResources().getString(
478 R.string.config_ims_rcs_package);
Brad Ebingerd1947d82021-05-17 20:54:49 +0000479 ImsResolver.make(this, defaultImsMmtelPackage,
Brad Ebingere3ae65a2020-09-11 12:45:11 -0700480 defaultImsRcsPackage, PhoneFactory.getPhones().length,
481 new ImsFeatureBinderRepository());
Brad Ebingerd1947d82021-05-17 20:54:49 +0000482 ImsResolver.getInstance().initialize();
Tyler Gunn92479152021-01-20 16:30:10 -0800483
484 // With the IMS phone created, load static config.xml values from the phone process
485 // so that it can be provided to the ImsPhoneCallTracker.
486 for (Phone p : PhoneFactory.getPhones()) {
487 Phone imsPhone = p.getImsPhone();
488 if (imsPhone != null && imsPhone instanceof ImsPhone) {
489 ImsPhone theImsPhone = (ImsPhone) imsPhone;
490 if (theImsPhone.getCallTracker() instanceof ImsPhoneCallTracker) {
491 ImsPhoneCallTracker ict = (ImsPhoneCallTracker)
492 theImsPhone.getCallTracker();
493
494 ImsPhoneCallTracker.Config config = new ImsPhoneCallTracker.Config();
495 config.isD2DCommunicationSupported = getResources().getBoolean(
496 R.bool.config_use_device_to_device_communication);
497 ict.setConfig(config);
498 }
499 }
500 }
Hui Wang068ab862020-10-31 05:12:53 +0000501 RcsProvisioningMonitor.make(this);
Brad Ebinger05f52c22019-12-05 13:03:21 -0800502 }
503
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700504 // Start TelephonyDebugService After the default phone is created.
505 Intent intent = new Intent(this, TelephonyDebugService.class);
506 startService(intent);
507
508 mCM = CallManager.getInstance();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700509
510 // Create the NotificationMgr singleton, which is used to display
511 // status bar icons and control other status bar behavior.
512 notificationMgr = NotificationMgr.init(this);
513
Aishwarya Mallampati481aeee2023-02-17 21:32:22 +0000514 // Create the SatelliteController singleton, which acts as a backend service for
515 // {@link android.telephony.satellite.SatelliteManager}.
516 SatelliteController.make(this);
Sarah Chin5f57c582023-02-14 04:16:10 -0800517
Anthony Lee03ebdfc2015-07-27 08:12:02 -0700518 // Create an instance of CdmaPhoneCallState and initialize it to IDLE
519 cdmaPhoneCallState = new CdmaPhoneCallState();
520 cdmaPhoneCallState.CdmaPhoneCallStateInit();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700521
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700522 // before registering for phone state changes
523 mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
524 mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, LOG_TAG);
525 // lock used to keep the processor awake, when we don't care for the display.
526 mPartialWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
527 | PowerManager.ON_AFTER_RELEASE, LOG_TAG);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700528
529 mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
530
Nazanin Bakhshi2f2cc692018-12-11 15:15:39 -0800531 phoneMgr = PhoneInterfaceManager.init(this);
Santos Cordon406c0342013-08-28 00:07:47 -0700532
James.cf Linaf3183c2019-10-24 00:59:00 +0800533 imsRcsController = ImsRcsController.init(this);
534
Brad Ebinger6c53e7f2023-01-27 16:26:44 -0800535 configLoader = CarrierConfigLoader.init(this);
536
James.cf Linc9f35a42020-01-15 02:35:22 +0800537 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS)) {
Hunsuk Choi3b742d62021-10-25 19:48:34 +0000538 mImsStateCallbackController =
539 ImsStateCallbackController.make(this, PhoneFactory.getPhones().length);
Brad Ebingera68a4972020-01-30 17:31:23 -0800540 mTelephonyRcsService = new TelephonyRcsService(this,
541 PhoneFactory.getPhones().length);
542 mTelephonyRcsService.initialize();
James.cf Linc9f35a42020-01-15 02:35:22 +0800543 imsRcsController.setRcsService(mTelephonyRcsService);
joonhunshincffb7fc2021-11-28 07:32:01 +0000544 mImsProvisioningController =
545 ImsProvisioningController.make(this, PhoneFactory.getPhones().length);
James.cf Linc9f35a42020-01-15 02:35:22 +0800546 }
547
Jack Yu1a2fc352017-07-14 17:14:37 -0700548 // Create the CallNotifier singleton, which handles
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700549 // asynchronous events from the telephony layer (like
550 // launching the incoming-call UI when an incoming call comes
551 // in.)
Brad Ebingera9c6b6d2016-01-07 17:24:16 -0800552 notifier = CallNotifier.init(this);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700553
Stuart Scottdcf40a92014-12-09 10:45:01 -0800554 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700555
556 // register for MMI/USSD
557 mCM.registerForMmiComplete(mHandler, MMI_COMPLETE, null);
558
Qiong Liucc3fe812019-09-23 15:25:44 +0800559 // Initialize cell status using current airplane mode.
Taesu Lee62f826d2020-08-10 16:01:18 +0900560 handleAirplaneModeChange(
561 Settings.Global.getInt(
562 getContentResolver(),
563 Settings.Global.AIRPLANE_MODE_ON,
564 AIRPLANE_OFF)
565 == AIRPLANE_ON);
Qiong Liucc3fe812019-09-23 15:25:44 +0800566
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700567 // Register for misc other intent broadcasts.
568 IntentFilter intentFilter =
569 new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700570 intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
571 intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700572 intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
Jack Yu1a2fc352017-07-14 17:14:37 -0700573 intentFilter.addAction(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
574 intentFilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700575 registerReceiver(mReceiver, intentFilter);
576
Sarah Chin072ffb22022-05-03 17:58:59 -0700577 PhoneConfigurationManager.registerForMultiSimConfigChange(
578 mHandler, EVENT_MULTI_SIM_CONFIG_CHANGED, null);
579
580 mTelephonyCallbacks = new PhoneAppCallback[tm.getSupportedModemCount()];
Fangyuan Li7f5c2752022-06-29 18:02:31 +0800581 if (tm.getSupportedModemCount() > 0) {
582 for (Phone phone : PhoneFactory.getPhones()) {
583 int subId = phone.getSubId();
584 PhoneAppCallback callback = new PhoneAppCallback(subId);
585 tm.createForSubscriptionId(subId).registerTelephonyCallback(
586 TelephonyManager.INCLUDE_LOCATION_DATA_NONE, mHandler::post, callback);
587 mTelephonyCallbacks[phone.getPhoneId()] = callback;
588 }
Sarah Chin072ffb22022-05-03 17:58:59 -0700589 }
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -0700590 mCarrierVvmPackageInstalledReceiver.register(this);
591
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700592 //set the default values for the preferences in the phone.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700593 PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700594 }
595
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700596 // XXX pre-load the SimProvider so that it's ready
597 resolver.getType(Uri.parse("content://icc/adn"));
598
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700599 // TODO: Register for Cdma Information Records
600 // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null);
601
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700602 // Read HAC settings and configure audio hardware
603 if (getResources().getBoolean(R.bool.hac_enabled)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800604 int hac = android.provider.Settings.System.getInt(
605 getContentResolver(),
606 android.provider.Settings.System.HEARING_AID,
607 0);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700608 AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
Jordan Liuf71aeef2019-08-21 11:46:09 -0700609 audioManager.setParameters(
610 SettingsConstants.HAC_KEY + "=" + (hac == SettingsConstants.HAC_ENABLED
611 ? SettingsConstants.HAC_VAL_ON : SettingsConstants.HAC_VAL_OFF));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700612 }
Siim Sammul182d61b2021-05-04 16:01:42 +0100613
614 // Start tracking Binder latency for the phone process.
615 mBinderCallsSettingsObserver = new BinderCallsStats.SettingsObserver(
616 getApplicationContext(),
Siim Sammula6950092021-06-22 17:14:03 +0100617 new BinderCallsStats(
618 new BinderCallsStats.Injector(),
619 com.android.internal.os.BinderLatencyProto.Dims.TELEPHONY));
Santos Cordonff506f52013-11-21 19:13:19 -0800620 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700621
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700622 /**
623 * Returns the singleton instance of the PhoneApp.
624 */
Sailesh Nepal1eaf22b2014-02-22 17:00:49 -0800625 public static PhoneGlobals getInstance() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700626 if (sMe == null) {
627 throw new IllegalStateException("No PhoneGlobals here!");
628 }
629 return sMe;
630 }
631
632 /**
Stuart Scottdcf40a92014-12-09 10:45:01 -0800633 * Returns the default phone.
634 *
Andrew Lee385019f2014-11-24 14:19:50 -0800635 * WARNING: This method should be used carefully, now that there may be multiple phones.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700636 */
Andrew Lee83383e42014-10-31 12:42:28 -0700637 public static Phone getPhone() {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800638 return PhoneFactory.getDefaultPhone();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700639 }
640
Andrew Lee2fcb6c32014-12-04 14:52:35 -0800641 public static Phone getPhone(int subId) {
642 return PhoneFactory.getPhone(SubscriptionManager.getPhoneId(subId));
Andrew Lee385019f2014-11-24 14:19:50 -0800643 }
644
Santos Cordonde10b752013-09-19 04:11:33 -0700645 /* package */ CallManager getCallManager() {
646 return mCM;
647 }
648
Chris Manton4e9fa912015-06-19 11:26:57 -0700649 public PersistableBundle getCarrierConfig() {
Shishir Agrawald3480e02016-01-25 13:05:49 -0800650 return getCarrierConfigForSubId(SubscriptionManager.getDefaultSubscriptionId());
Jonathan Basseri89b0ab42015-05-01 10:52:40 -0700651 }
652
Chris Manton4e9fa912015-06-19 11:26:57 -0700653 public PersistableBundle getCarrierConfigForSubId(int subId) {
Philip P. Moltmann0079aae2020-03-05 16:24:02 -0800654 return configLoader.getConfigForSubIdWithFeature(subId, getOpPackageName(),
655 getAttributionTag());
Junda Liu605148f2015-04-28 15:23:40 -0700656 }
657
Jack Yu1a2fc352017-07-14 17:14:37 -0700658 private void registerSettingsObserver() {
659 mSettingsObserver.unobserve();
660 String dataRoamingSetting = Settings.Global.DATA_ROAMING;
661 String mobileDataSetting = Settings.Global.MOBILE_DATA;
662 if (TelephonyManager.getDefault().getSimCount() > 1) {
663 int subId = mDefaultDataSubId;
664 if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
665 dataRoamingSetting += subId;
666 mobileDataSetting += subId;
667 }
668 }
669
670 // Listen for user data roaming setting changed event
671 mSettingsObserver.observe(Settings.Global.getUriFor(dataRoamingSetting),
672 EVENT_DATA_ROAMING_SETTINGS_CHANGED);
673
674 // Listen for mobile data setting changed event
675 mSettingsObserver.observe(Settings.Global.getUriFor(mobileDataSetting),
676 EVENT_MOBILE_DATA_SETTINGS_CHANGED);
677 }
678
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700679 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700680 * Sets the activity responsible for un-PUK-blocking the device
681 * so that we may close it when we receive a positive result.
682 * mPUKEntryActivity is also used to indicate to the device that
683 * we are trying to un-PUK-lock the phone. In other words, iff
684 * it is NOT null, then we are trying to unlock and waiting for
685 * the SIM to move to READY state.
686 *
687 * @param activity is the activity to close when PUK has
688 * finished unlocking. Can be set to null to indicate the unlock
689 * or SIM READYing process is over.
690 */
691 void setPukEntryActivity(Activity activity) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700692 Log.i(LOG_TAG, "setPukEntryActivity - set to " + (activity == null ? "null" : "activity"));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700693 mPUKEntryActivity = activity;
694 }
695
696 Activity getPUKEntryActivity() {
697 return mPUKEntryActivity;
698 }
699
700 /**
701 * Sets the dialog responsible for notifying the user of un-PUK-
702 * blocking - SIM READYing progress, so that we may dismiss it
703 * when we receive a positive result.
704 *
705 * @param dialog indicates the progress dialog informing the user
706 * of the state of the device. Dismissed upon completion of
707 * READYing process
708 */
709 void setPukEntryProgressDialog(ProgressDialog dialog) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700710 Log.i(LOG_TAG, "setPukEntryProgressDialog - set to "
711 + (dialog == null ? "null" : "activity"));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700712 mPUKEntryProgressDialog = dialog;
713 }
714
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700715 KeyguardManager getKeyguardManager() {
716 return mKeyguardManager;
717 }
718
719 private void onMMIComplete(AsyncResult r) {
720 if (VDBG) Log.d(LOG_TAG, "onMMIComplete()...");
721 MmiCode mmiCode = (MmiCode) r.result;
Stuart Scottdcf40a92014-12-09 10:45:01 -0800722 PhoneUtils.displayMMIComplete(mmiCode.getPhone(), getInstance(), mmiCode, null, null);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700723 }
724
fionaxu80126972017-02-01 17:01:26 -0800725 private void initForNewRadioTechnology() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700726 if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology...");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700727 notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700728 }
729
Taesu Lee62f826d2020-08-10 16:01:18 +0900730 private void handleAirplaneModeChange(boolean isAirplaneNewlyOn) {
Sarah Chin9ec6e1e2022-08-10 13:29:40 -0700731 Log.i(LOG_TAG, "handleAirplaneModeChange: isAirplaneNewlyOn=" + isAirplaneNewlyOn);
Taesu Lee62f826d2020-08-10 16:01:18 +0900732 int cellState =
733 Settings.Global.getInt(
734 getContentResolver(), Settings.Global.CELL_ON, PhoneConstants.CELL_ON_FLAG);
Chris Mantona09f3632016-02-09 14:48:42 -0800735 switch (cellState) {
736 case PhoneConstants.CELL_OFF_FLAG:
Sarah Chin9ec6e1e2022-08-10 13:29:40 -0700737 // Airplane mode does not affect the cell radio if user has turned it off.
738 Log.i(LOG_TAG, "Ignore airplane mode change due to cell off.");
Chris Mantona09f3632016-02-09 14:48:42 -0800739 break;
740 case PhoneConstants.CELL_ON_FLAG:
Taesu Lee62f826d2020-08-10 16:01:18 +0900741 maybeTurnCellOff(isAirplaneNewlyOn);
Chris Mantona09f3632016-02-09 14:48:42 -0800742 break;
743 case PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG:
Taesu Lee62f826d2020-08-10 16:01:18 +0900744 maybeTurnCellOn(isAirplaneNewlyOn);
Chris Mantona09f3632016-02-09 14:48:42 -0800745 break;
746 }
Hall Liu7f56e1a2019-07-10 14:41:14 -0700747 for (Phone phone : PhoneFactory.getPhones()) {
748 phone.getServiceStateTracker().onAirplaneModeChanged(isAirplaneNewlyOn);
749 }
Chris Mantona09f3632016-02-09 14:48:42 -0800750 }
751
752 /*
753 * Returns true if the radio must be turned off when entering airplane mode.
754 */
Taesu Lee62f826d2020-08-10 16:01:18 +0900755 private boolean isCellOffInAirplaneMode() {
756 String airplaneModeRadios =
757 Settings.Global.getString(
758 getContentResolver(), Settings.Global.AIRPLANE_MODE_RADIOS);
Chris Mantona09f3632016-02-09 14:48:42 -0800759 return airplaneModeRadios == null
760 || airplaneModeRadios.contains(Settings.Global.RADIO_CELL);
761 }
762
Taesu Lee62f826d2020-08-10 16:01:18 +0900763 private void setRadioPowerOff() {
Chris Mantona09f3632016-02-09 14:48:42 -0800764 Log.i(LOG_TAG, "Turning radio off - airplane");
Taesu Lee62f826d2020-08-10 16:01:18 +0900765 Settings.Global.putInt(
766 getContentResolver(),
767 Settings.Global.CELL_ON,
768 PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG);
Chris Mantona09f3632016-02-09 14:48:42 -0800769 Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT, 0);
Taesu Lee62f826d2020-08-10 16:01:18 +0900770 TelephonyProperties.airplane_mode_on(true); // true means int value 1
Chris Mantona09f3632016-02-09 14:48:42 -0800771 PhoneUtils.setRadioPower(false);
Ling Ma317906d2022-12-05 15:58:14 -0800772 clearCacheOnRadioOff();
773 }
774
775 /** Clear fields on power off radio **/
776 private void clearCacheOnRadioOff() {
777 // Re-show is-roaming notifications after APM mode
778 mPrevRoamingOperatorNumerics.clear();
Chris Mantona09f3632016-02-09 14:48:42 -0800779 }
780
Taesu Lee62f826d2020-08-10 16:01:18 +0900781 private void setRadioPowerOn() {
Chris Mantona09f3632016-02-09 14:48:42 -0800782 Log.i(LOG_TAG, "Turning radio on - airplane");
Taesu Lee62f826d2020-08-10 16:01:18 +0900783 Settings.Global.putInt(
784 getContentResolver(), Settings.Global.CELL_ON, PhoneConstants.CELL_ON_FLAG);
785 Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT, 1);
Meng Wang61307622019-10-23 14:08:43 -0700786 TelephonyProperties.airplane_mode_on(false); // false means int value 0
Chris Mantona09f3632016-02-09 14:48:42 -0800787 PhoneUtils.setRadioPower(true);
788 }
789
Taesu Lee62f826d2020-08-10 16:01:18 +0900790 private void maybeTurnCellOff(boolean isAirplaneNewlyOn) {
Chris Mantona09f3632016-02-09 14:48:42 -0800791 if (isAirplaneNewlyOn) {
Santos Cordone18902f2016-03-22 17:16:04 -0700792 // If we are trying to turn off the radio, make sure there are no active
793 // emergency calls. If there are, switch airplane mode back to off.
Taesu Lee62f826d2020-08-10 16:01:18 +0900794 TelecomManager tm = (TelecomManager) getSystemService(TELECOM_SERVICE);
Tyler Gunn900d8fd2018-09-21 09:22:12 -0700795
796 if (tm != null && tm.isInEmergencyCall()) {
Santos Cordone18902f2016-03-22 17:16:04 -0700797 // Switch airplane mode back to off.
Jordan Liu0e819b12019-08-28 15:33:05 -0700798 ConnectivityManager cm =
Taesu Lee62f826d2020-08-10 16:01:18 +0900799 (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
Jordan Liu0e819b12019-08-28 15:33:05 -0700800 cm.setAirplaneMode(false);
Santos Cordone18902f2016-03-22 17:16:04 -0700801 Toast.makeText(this, R.string.radio_off_during_emergency_call, Toast.LENGTH_LONG)
802 .show();
803 Log.i(LOG_TAG, "Ignoring airplane mode: emergency call. Turning airplane off");
Taesu Lee62f826d2020-08-10 16:01:18 +0900804 } else if (isCellOffInAirplaneMode()) {
805 setRadioPowerOff();
Santos Cordone18902f2016-03-22 17:16:04 -0700806 } else {
Chris Mantona09f3632016-02-09 14:48:42 -0800807 Log.i(LOG_TAG, "Ignoring airplane mode: settings prevent cell radio power off");
Santos Cordone18902f2016-03-22 17:16:04 -0700808 }
Sarah Chin9ec6e1e2022-08-10 13:29:40 -0700809 } else {
810 Log.i(LOG_TAG, "Ignoring airplane mode: not newly on");
Chris Mantona09f3632016-02-09 14:48:42 -0800811 }
812 }
813
Taesu Lee62f826d2020-08-10 16:01:18 +0900814 private void maybeTurnCellOn(boolean isAirplaneNewlyOn) {
Chris Mantona09f3632016-02-09 14:48:42 -0800815 if (!isAirplaneNewlyOn) {
Taesu Lee62f826d2020-08-10 16:01:18 +0900816 setRadioPowerOn();
Sarah Chin9ec6e1e2022-08-10 13:29:40 -0700817 } else {
818 Log.i(LOG_TAG, "Ignoring airplane mode off: radio is already on.");
Santos Cordone18902f2016-03-22 17:16:04 -0700819 }
820 }
821
Santos Cordon593ab382013-08-06 21:58:23 -0700822 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700823 * Receiver for misc intent broadcasts the Phone app cares about.
824 */
825 private class PhoneAppBroadcastReceiver extends BroadcastReceiver {
826 @Override
827 public void onReceive(Context context, Intent intent) {
828 String action = intent.getAction();
829 if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
Taesu Lee3dc572b2020-08-07 18:16:22 +0900830 boolean airplaneMode = intent.getBooleanExtra("state", false);
Taesu Lee62f826d2020-08-10 16:01:18 +0900831 handleAirplaneModeChange(airplaneMode);
Amit Mahajanf5d92c82018-11-02 17:44:40 -0700832 } else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
833 // re-register as it may be a new IccCard
834 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY,
835 SubscriptionManager.INVALID_PHONE_INDEX);
836 if (SubscriptionManager.isValidPhoneId(phoneId)) {
837 PhoneUtils.unregisterIccStatus(mHandler, phoneId);
838 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED, phoneId);
839 }
Nazish Tabassum160d2112019-12-23 17:31:33 +0530840 String iccStatus = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
841 mHandler.sendMessage(mHandler.obtainMessage(EVENT_SIM_STATE_CHANGED,
842 new EventSimStateChangedBag(phoneId, iccStatus)));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700843 } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) {
844 String newPhone = intent.getStringExtra(PhoneConstants.PHONE_NAME_KEY);
fionaxu80126972017-02-01 17:01:26 -0800845 Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active.");
846 initForNewRadioTechnology();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700847 } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530848 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY, 0);
Srikanth Chintala079912a2016-03-03 16:35:01 +0530849 phoneInEcm = PhoneFactory.getPhone(phoneId);
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530850 Log.d(LOG_TAG, "Emergency Callback Mode. phoneId:" + phoneId);
851 if (phoneInEcm != null) {
852 if (TelephonyCapabilities.supportsEcm(phoneInEcm)) {
853 Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp.");
854 // Start Emergency Callback Mode service
Daniel Bright30efde42020-01-09 22:11:15 -0800855 if (intent.getBooleanExtra(
856 TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, false)) {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530857 context.startService(new Intent(context,
858 EmergencyCallbackModeService.class));
859 } else {
860 phoneInEcm = null;
861 }
862 } else {
863 // It doesn't make sense to get ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
864 // on a device that doesn't support ECM in the first place.
865 Log.e(LOG_TAG, "Got ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, but "
866 + "ECM isn't supported for phone: " + phoneInEcm.getPhoneName());
867 phoneInEcm = null;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700868 }
869 } else {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530870 Log.w(LOG_TAG, "phoneInEcm is null.");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700871 }
Jack Yu1a2fc352017-07-14 17:14:37 -0700872 } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) {
873 // Roaming status could be overridden by carrier config, so we need to update it.
874 if (VDBG) Log.v(LOG_TAG, "carrier config changed.");
875 updateDataRoamingStatus();
chen xubaf9fe52019-07-02 17:28:24 -0700876 updateLimitedSimFunctionForDualSim();
Lei Liu863eac02020-06-24 20:12:55 +0800877 int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
878 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
879 if (SubscriptionManager.isValidSubscriptionId(subId)) {
880 mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARRIER_CONFIG_CHANGED,
881 new Integer(subId)));
882 }
Jack Yu1a2fc352017-07-14 17:14:37 -0700883 } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
884 // We also need to pay attention when default data subscription changes.
885 if (VDBG) Log.v(LOG_TAG, "default data sub changed.");
886 mDefaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
887 registerSettingsObserver();
888 Phone phone = getPhone(mDefaultDataSubId);
889 if (phone != null) {
890 updateDataRoamingStatus();
891 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700892 }
893 }
894 }
895
Sarah Chin072ffb22022-05-03 17:58:59 -0700896 private void handleServiceStateChanged(ServiceState serviceState, int subId) {
Jack Yu1a2fc352017-07-14 17:14:37 -0700897 if (VDBG) Log.v(LOG_TAG, "handleServiceStateChanged");
Sarah Chin072ffb22022-05-03 17:58:59 -0700898 int state = serviceState.getState();
899 notificationMgr.updateNetworkSelection(state, subId);
Jack Yu1a2fc352017-07-14 17:14:37 -0700900
Sarah Chin072ffb22022-05-03 17:58:59 -0700901 if (VDBG) {
902 Log.v(LOG_TAG, "subId=" + subId + ", mDefaultDataSubId="
903 + mDefaultDataSubId + ", ss roaming=" + serviceState.getDataRoaming());
904 }
905 if (subId == mDefaultDataSubId) {
Ling Ma317906d2022-12-05 15:58:14 -0800906 updateDataRoamingStatus(serviceState.getOperatorNumeric());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700907 }
908 }
909
Jack Yu1a2fc352017-07-14 17:14:37 -0700910 /**
911 * When roaming, if mobile data cannot be established due to data roaming not enabled, we need
912 * to notify the user so they can enable it through settings. Vise versa if the condition
913 * changes, we need to dismiss the notification.
914 */
915 private void updateDataRoamingStatus() {
Ling Ma317906d2022-12-05 15:58:14 -0800916 updateDataRoamingStatus(null /*roamingOperatorNumeric*/);
917 }
918
919 /**
920 * When roaming, if mobile data cannot be established due to data roaming not enabled, we need
921 * to notify the user so they can enable it through settings. Vise versa if the condition
922 * changes, we need to dismiss the notification.
923 * @param roamingOperatorNumeric The operator numeric for the current roaming. {@code null} if
924 * the current roaming operator numeric didn't change.
925 */
926 private void updateDataRoamingStatus(@Nullable String roamingOperatorNumeric) {
Jack Yu1a2fc352017-07-14 17:14:37 -0700927 if (VDBG) Log.v(LOG_TAG, "updateDataRoamingStatus");
928 Phone phone = getPhone(mDefaultDataSubId);
929 if (phone == null) {
930 Log.w(LOG_TAG, "Can't get phone with sub id = " + mDefaultDataSubId);
931 return;
932 }
933
Jack Yu3e2ac6e2022-03-26 13:59:45 -0700934 boolean dataAllowed;
935 boolean notAllowedDueToRoamingOff;
Sarah Chine04784a2022-10-31 20:32:34 -0700936 List<DataDisallowedReason> reasons = phone.getDataNetworkController()
937 .getInternetDataDisallowedReasons();
Jack Yu7968c6d2022-07-31 00:43:21 -0700938 dataAllowed = reasons.isEmpty();
939 notAllowedDueToRoamingOff = (reasons.size() == 1
940 && reasons.contains(DataDisallowedReason.ROAMING_DISABLED));
Ling Ma317906d2022-12-05 15:58:14 -0800941 mDataRoamingNotifLog.log("dataAllowed=" + dataAllowed + ", reasons=" + reasons
942 + ", roamingOperatorNumeric=" + roamingOperatorNumeric);
943 if (VDBG) {
944 Log.v(LOG_TAG, "dataAllowed=" + dataAllowed + ", reasons=" + reasons
945 + ", roamingOperatorNumeric=" + roamingOperatorNumeric);
946 }
Jack Yu3e2ac6e2022-03-26 13:59:45 -0700947
948 if (!dataAllowed && notAllowedDueToRoamingOff) {
Ling Ma4e15c322022-12-07 11:20:53 -0800949 // Don't show roaming notification if we've already shown for this MccMnc
950 if (roamingOperatorNumeric != null
951 && !mPrevRoamingOperatorNumerics.add(roamingOperatorNumeric)) {
952 Log.d(LOG_TAG, "Skip roaming disconnected notification since already shown in "
953 + "MccMnc " + roamingOperatorNumeric);
954 return;
955 }
Jordan Liuff2ccd72019-07-23 15:54:41 -0700956 // No need to show it again if we never cancelled it explicitly.
957 if (mPrevRoamingNotification == ROAMING_NOTIFICATION_DISCONNECTED) return;
Jack Yu1a2fc352017-07-14 17:14:37 -0700958 // If the only reason of no data is data roaming disabled, then we notify the user
959 // so the user can turn on data roaming.
Jordan Liuff2ccd72019-07-23 15:54:41 -0700960 mPrevRoamingNotification = ROAMING_NOTIFICATION_DISCONNECTED;
Jack Yu1a2fc352017-07-14 17:14:37 -0700961 Log.d(LOG_TAG, "Show roaming disconnected notification");
Jordan Liuff2ccd72019-07-23 15:54:41 -0700962 mDataRoamingNotifLog.log("Show roaming off.");
Pengquan Meng8783d932017-10-16 14:57:40 -0700963 Message msg = mHandler.obtainMessage(EVENT_DATA_ROAMING_DISCONNECTED);
964 msg.arg1 = mDefaultDataSubId;
965 msg.sendToTarget();
Ling Ma317906d2022-12-05 15:58:14 -0800966 } else if (dataAllowed && dataIsNowRoaming(mDefaultDataSubId)) {
Ling Ma4e15c322022-12-07 11:20:53 -0800967 boolean isShowRoamingNotificationEnabled = getCarrierConfigForSubId(mDefaultDataSubId)
968 .getBoolean(CarrierConfigManager
969 .KEY_SHOW_DATA_CONNECTED_ROAMING_NOTIFICATION_BOOL);
970 if (!isShowRoamingNotificationEnabled) return;
971 // Don't show roaming notification if we've already shown for this MccMnc
972 if (roamingOperatorNumeric != null
973 && !mPrevRoamingOperatorNumerics.add(roamingOperatorNumeric)) {
974 Log.d(LOG_TAG, "Skip roaming connected notification since already shown in "
975 + "MccMnc " + roamingOperatorNumeric);
976 return;
977 }
Jordan Liuff2ccd72019-07-23 15:54:41 -0700978 // No need to show it again if we never cancelled it explicitly, or carrier config
979 // indicates this is not needed.
980 if (mPrevRoamingNotification == ROAMING_NOTIFICATION_CONNECTED) return;
981 mPrevRoamingNotification = ROAMING_NOTIFICATION_CONNECTED;
982 Log.d(LOG_TAG, "Show roaming connected notification");
983 mDataRoamingNotifLog.log("Show roaming on.");
984 Message msg = mHandler.obtainMessage(EVENT_DATA_ROAMING_CONNECTED);
985 msg.arg1 = mDefaultDataSubId;
986 msg.sendToTarget();
987 } else if (mPrevRoamingNotification != ROAMING_NOTIFICATION_NO_NOTIFICATION) {
988 // Otherwise we either 1) we are not roaming or 2) roaming is off but ROAMING_DISABLED
989 // is not the only data disable reason. In this case we dismiss the notification we
990 // showed earlier.
991 mPrevRoamingNotification = ROAMING_NOTIFICATION_NO_NOTIFICATION;
992 Log.d(LOG_TAG, "Dismiss roaming notification");
Jack Yu3e2ac6e2022-03-26 13:59:45 -0700993 mDataRoamingNotifLog.log("Hide. data allowed=" + dataAllowed);
Jack Yu1a2fc352017-07-14 17:14:37 -0700994 mHandler.sendEmptyMessage(EVENT_DATA_ROAMING_OK);
995 }
996 }
997
Jordan Liuff2ccd72019-07-23 15:54:41 -0700998 /**
999 *
1000 * @param subId to check roaming on
1001 * @return whether we have transitioned to dataRoaming
1002 */
1003 private boolean dataIsNowRoaming(int subId) {
Sarah Chine04784a2022-10-31 20:32:34 -07001004 return getPhone(subId).getServiceState().getDataRoaming();
Jordan Liuff2ccd72019-07-23 15:54:41 -07001005 }
1006
chen xubaf9fe52019-07-02 17:28:24 -07001007 private void updateLimitedSimFunctionForDualSim() {
1008 if (DBG) Log.d(LOG_TAG, "updateLimitedSimFunctionForDualSim");
1009 // check conditions to display limited SIM function notification under dual SIM
1010 SubscriptionManager subMgr = (SubscriptionManager) getSystemService(
1011 Context.TELEPHONY_SUBSCRIPTION_SERVICE);
1012 List<SubscriptionInfo> subList = subMgr.getActiveSubscriptionInfoList(false);
1013 if (subList != null && subList.size() > 1) {
1014 CarrierConfigManager configMgr = (CarrierConfigManager)
1015 getSystemService(Context.CARRIER_CONFIG_SERVICE);
1016 for (SubscriptionInfo info : subList) {
1017 PersistableBundle b = configMgr.getConfigForSubId(info.getSubscriptionId());
1018 if (b != null) {
1019 if (b.getBoolean(CarrierConfigManager
1020 .KEY_LIMITED_SIM_FUNCTION_NOTIFICATION_FOR_DSDS_BOOL)) {
1021 notificationMgr.showLimitedSimFunctionWarningNotification(
1022 info.getSubscriptionId(),
1023 info.getDisplayName().toString());
1024 } else {
1025 notificationMgr.dismissLimitedSimFunctionWarningNotification(
1026 info.getSubscriptionId());
1027 }
1028 }
1029 }
1030 } else {
1031 // cancel notifications for all subs
1032 notificationMgr.dismissLimitedSimFunctionWarningNotification(
1033 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
1034 }
1035 notificationMgr.dismissLimitedSimFunctionWarningNotificationForInactiveSubs();
1036
1037 }
1038
Sandeep Kuntade73a6a2014-10-15 18:45:56 +05301039 public Phone getPhoneInEcm() {
1040 return phoneInEcm;
1041 }
1042
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001043 /**
Tyler Gunn9c1071f2014-12-09 10:07:54 -08001044 * Triggers a refresh of the message waiting (voicemail) indicator.
1045 *
1046 * @param subId the subscription id we should refresh the notification for.
1047 */
1048 public void refreshMwiIndicator(int subId) {
1049 notificationMgr.refreshMwi(subId);
1050 }
1051
1052 /**
Pengquan Mengdd9ac822018-09-20 15:25:35 -07001053 * Called when the network selection on the subscription {@code subId} is changed by the user.
1054 *
1055 * @param subId the subscription id.
1056 */
1057 public void onNetworkSelectionChanged(int subId) {
1058 Phone phone = getPhone(subId);
1059 if (phone != null) {
1060 notificationMgr.updateNetworkSelection(phone.getServiceState().getState(), subId);
1061 } else {
1062 Log.w(LOG_TAG, "onNetworkSelectionChanged on null phone, subId: " + subId);
1063 }
1064 }
1065
1066 /**
James.cf Lin4b784aa2021-01-31 03:25:15 +08001067 * @return whether the device supports RCS User Capability Exchange or not.
1068 */
1069 public boolean getDeviceUceEnabled() {
1070 return (mTelephonyRcsService == null) ? false : mTelephonyRcsService.isDeviceUceEnabled();
1071 }
1072
1073 /**
1074 * Set the device supports RCS User Capability Exchange.
1075 * @param isEnabled true if the device supports UCE.
1076 */
1077 public void setDeviceUceEnabled(boolean isEnabled) {
1078 if (mTelephonyRcsService != null) {
1079 mTelephonyRcsService.setDeviceUceEnabled(isEnabled);
1080 }
1081 }
1082
1083 /**
Jack Yu1a2fc352017-07-14 17:14:37 -07001084 * Dump the state of the object, add calls to other objects as desired.
1085 *
1086 * @param fd File descriptor
1087 * @param printWriter Print writer
1088 * @param args Arguments
1089 */
1090 public void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) {
1091 IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " ");
1092 pw.println("------- PhoneGlobals -------");
1093 pw.increaseIndent();
Jordan Liuff2ccd72019-07-23 15:54:41 -07001094 pw.println("mPrevRoamingNotification=" + mPrevRoamingNotification);
Jack Yu1a2fc352017-07-14 17:14:37 -07001095 pw.println("mDefaultDataSubId=" + mDefaultDataSubId);
1096 pw.println("mDataRoamingNotifLog:");
Keun young Parkdebb8532019-05-30 16:35:27 -07001097 pw.println("isSmsCapable=" + TelephonyManager.from(this).isSmsCapable());
Jack Yu1a2fc352017-07-14 17:14:37 -07001098 pw.increaseIndent();
1099 mDataRoamingNotifLog.dump(fd, pw, args);
1100 pw.decreaseIndent();
Brad Ebinger05f52c22019-12-05 13:03:21 -08001101 pw.println("ImsResolver:");
1102 pw.increaseIndent();
1103 try {
Brad Ebingerd1947d82021-05-17 20:54:49 +00001104 if (ImsResolver.getInstance() != null) ImsResolver.getInstance().dump(fd, pw, args);
Brad Ebinger05f52c22019-12-05 13:03:21 -08001105 } catch (Exception e) {
1106 e.printStackTrace();
1107 }
1108 pw.decreaseIndent();
Brad Ebingera68a4972020-01-30 17:31:23 -08001109 pw.println("RcsService:");
1110 try {
1111 if (mTelephonyRcsService != null) mTelephonyRcsService.dump(fd, pw, args);
1112 } catch (Exception e) {
1113 e.printStackTrace();
1114 }
Hunsuk Choi89bd22c2021-11-01 13:04:54 +00001115 pw.println("ImsStateCallbackController:");
1116 try {
1117 if (mImsStateCallbackController != null) mImsStateCallbackController.dump(pw);
1118 } catch (Exception e) {
1119 e.printStackTrace();
1120 }
Hwangoo Parkba21cf22022-11-30 14:34:04 +00001121 pw.println("DomainSelectionResolver:");
1122 pw.increaseIndent();
1123 try {
1124 if (DomainSelectionResolver.getInstance() != null) {
1125 DomainSelectionResolver.getInstance().dump(fd, pw, args);
1126 }
1127 } catch (Exception e) {
1128 e.printStackTrace();
1129 }
1130 pw.decreaseIndent();
1131 if (mDomainSelectionService != null) {
1132 mDomainSelectionService.dump(fd, pw, args);
1133 }
Jack Yu1a2fc352017-07-14 17:14:37 -07001134 pw.decreaseIndent();
Ling Ma317906d2022-12-05 15:58:14 -08001135 pw.println("mPrevRoamingOperatorNumerics:" + mPrevRoamingOperatorNumerics);
Jack Yu1a2fc352017-07-14 17:14:37 -07001136 pw.println("------- End PhoneGlobals -------");
1137 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001138}