blob: 4e077e9fd45aff0dd7e4dc6542c06e69dc5c7b88 [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;
sangyun1c1918a2023-11-13 22:37:50 +090020import 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;
Sarah Chin37b39072023-11-05 13:28:21 -080053import android.text.TextUtils;
Ling Ma317906d2022-12-05 15:58:14 -080054import android.util.ArraySet;
Jack Yu1a2fc352017-07-14 17:14:37 -070055import android.util.LocalLog;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070056import android.util.Log;
Santos Cordone18902f2016-03-22 17:16:04 -070057import android.widget.Toast;
Ta-wei Yenb29425b2016-09-21 17:28:14 -070058
Brad Ebingere3ae65a2020-09-11 12:45:11 -070059import com.android.ims.ImsFeatureBinderRepository;
Siim Sammul182d61b2021-05-04 16:01:42 +010060import com.android.internal.os.BinderCallsStats;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070061import com.android.internal.telephony.CallManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070062import com.android.internal.telephony.IccCardConstants;
63import com.android.internal.telephony.MmiCode;
64import com.android.internal.telephony.Phone;
Sarah Chin072ffb22022-05-03 17:58:59 -070065import com.android.internal.telephony.PhoneConfigurationManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070066import com.android.internal.telephony.PhoneConstants;
67import com.android.internal.telephony.PhoneFactory;
Jack Yu1a2fc352017-07-14 17:14:37 -070068import com.android.internal.telephony.SettingsObserver;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070069import com.android.internal.telephony.TelephonyCapabilities;
Youming Ye47a6adc2018-11-19 15:33:36 -080070import com.android.internal.telephony.TelephonyComponentFactory;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070071import com.android.internal.telephony.TelephonyIntents;
Jack Yu3e2ac6e2022-03-26 13:59:45 -070072import com.android.internal.telephony.data.DataEvaluation.DataDisallowedReason;
Hwangoo Parkba21cf22022-11-30 14:34:04 +000073import com.android.internal.telephony.domainselection.DomainSelectionResolver;
Daniel Bantab26e96f2022-10-19 23:25:35 +000074import com.android.internal.telephony.emergency.EmergencyStateTracker;
Thomas Nguyen090fb002023-09-11 17:35:30 -070075import com.android.internal.telephony.flags.FeatureFlags;
Ling Ma51dd3022023-08-29 11:46:38 -070076import com.android.internal.telephony.flags.FeatureFlagsImpl;
Brad Ebinger05f52c22019-12-05 13:03:21 -080077import com.android.internal.telephony.ims.ImsResolver;
Tyler Gunn92479152021-01-20 16:30:10 -080078import com.android.internal.telephony.imsphone.ImsPhone;
79import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
Aishwarya Mallampati481aeee2023-02-17 21:32:22 +000080import com.android.internal.telephony.satellite.SatelliteController;
Nagendra Prasad Nagarle Basavarajuf668eda2024-02-15 15:02:57 +000081import com.android.internal.telephony.subscription.SubscriptionManagerService;
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +000082import com.android.internal.telephony.uicc.UiccPort;
Jordan Liu06bdef12021-03-24 17:25:46 -070083import com.android.internal.telephony.uicc.UiccProfile;
Jack Yu1a2fc352017-07-14 17:14:37 -070084import com.android.internal.util.IndentingPrintWriter;
Andrew Leefb7f92e2015-02-26 16:23:32 -080085import com.android.phone.settings.SettingsConstants;
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -070086import com.android.phone.vvm.CarrierVvmPackageInstalledReceiver;
James.cf Linc9f35a42020-01-15 02:35:22 +080087import com.android.services.telephony.rcs.TelephonyRcsService;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070088
Jack Yu1a2fc352017-07-14 17:14:37 -070089import java.io.FileDescriptor;
90import java.io.PrintWriter;
Jordan Liuff2ccd72019-07-23 15:54:41 -070091import java.lang.annotation.Retention;
92import java.lang.annotation.RetentionPolicy;
chen xubaf9fe52019-07-02 17:28:24 -070093import java.util.List;
sangyund2cfeaa2024-03-31 12:20:40 +090094import java.util.concurrent.atomic.AtomicBoolean;
Jack Yu1a2fc352017-07-14 17:14:37 -070095
Santos Cordon7d4ddf62013-07-10 11:58:08 -070096/**
97 * Global state for the telephony subsystem when running in the primary
98 * phone process.
99 */
Sailesh Nepalbf900542014-07-15 16:18:32 -0700100public class PhoneGlobals extends ContextWrapper {
Jack Yu1a2fc352017-07-14 17:14:37 -0700101 public static final String LOG_TAG = "PhoneGlobals";
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700102
103 /**
104 * Phone app-wide debug level:
105 * 0 - no debug logging
106 * 1 - normal debug logging if ro.debuggable is set (which is true in
107 * "eng" and "userdebug" builds but not "user" builds)
108 * 2 - ultra-verbose debug logging
109 *
110 * Most individual classes in the phone app have a local DBG constant,
111 * typically set to
112 * (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1)
113 * or else
114 * (PhoneApp.DBG_LEVEL >= 2)
115 * depending on the desired verbosity.
116 *
117 * ***** DO NOT SUBMIT WITH DBG_LEVEL > 0 *************
118 */
Andrew Lee88b51e22014-10-29 15:48:51 -0700119 public static final int DBG_LEVEL = 0;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700120
121 private static final boolean DBG =
122 (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
123 private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
124
125 // Message codes; see mHandler below.
126 private static final int EVENT_SIM_NETWORK_LOCKED = 3;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700127 private static final int EVENT_SIM_STATE_CHANGED = 8;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700128 private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10;
Jordan Liuff2ccd72019-07-23 15:54:41 -0700129 private static final int EVENT_DATA_ROAMING_CONNECTED = 11;
130 private static final int EVENT_DATA_ROAMING_OK = 12;
131 private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 13;
Jordan Liuff2ccd72019-07-23 15:54:41 -0700132 private static final int EVENT_DATA_ROAMING_SETTINGS_CHANGED = 15;
133 private static final int EVENT_MOBILE_DATA_SETTINGS_CHANGED = 16;
Lei Liu863eac02020-06-24 20:12:55 +0800134 private static final int EVENT_CARRIER_CONFIG_CHANGED = 17;
Sarah Chin072ffb22022-05-03 17:58:59 -0700135 private static final int EVENT_MULTI_SIM_CONFIG_CHANGED = 18;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700136
137 // The MMI codes are also used by the InCallScreen.
138 public static final int MMI_INITIATE = 51;
139 public static final int MMI_COMPLETE = 52;
140 public static final int MMI_CANCEL = 53;
141 // Don't use message codes larger than 99 here; those are reserved for
142 // the individual Activities of the Phone UI.
143
Santos Cordone18902f2016-03-22 17:16:04 -0700144 public static final int AIRPLANE_ON = 1;
145 public static final int AIRPLANE_OFF = 0;
146
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700147 /**
148 * Allowable values for the wake lock code.
149 * SLEEP means the device can be put to sleep.
150 * PARTIAL means wake the processor, but we display can be kept off.
151 * FULL means wake both the processor and the display.
152 */
153 public enum WakeState {
154 SLEEP,
155 PARTIAL,
156 FULL
157 }
158
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700159 private static PhoneGlobals sMe;
160
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700161 CallManager mCM;
Santos Cordon63a84242013-07-23 13:32:52 -0700162 CallNotifier notifier;
Santos Cordon63a84242013-07-23 13:32:52 -0700163 NotificationMgr notificationMgr;
James.cf Linc9f35a42020-01-15 02:35:22 +0800164 TelephonyRcsService mTelephonyRcsService;
Andrew Lee9431b832015-03-09 18:46:45 -0700165 public PhoneInterfaceManager phoneMgr;
James.cf Linaf3183c2019-10-24 00:59:00 +0800166 public ImsRcsController imsRcsController;
Hunsuk Choi3b742d62021-10-25 19:48:34 +0000167 public ImsStateCallbackController mImsStateCallbackController;
joonhunshincffb7fc2021-11-28 07:32:01 +0000168 public ImsProvisioningController mImsProvisioningController;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800169 CarrierConfigLoader configLoader;
Santos Cordon63a84242013-07-23 13:32:52 -0700170
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530171 private Phone phoneInEcm;
Santos Cordon63a84242013-07-23 13:32:52 -0700172
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700173 static boolean sVoiceCapable = true;
174
Santos Cordonc593d002015-06-03 15:41:15 -0700175 // TODO: Remove, no longer used.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700176 CdmaPhoneCallState cdmaPhoneCallState;
177
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700178 // The currently-active PUK entry activity and progress dialog.
179 // Normally, these are the Emergency Dialer and the subsequent
180 // progress dialog. null if there is are no such objects in
181 // the foreground.
182 private Activity mPUKEntryActivity;
183 private ProgressDialog mPUKEntryProgressDialog;
184
Jordan Liuff2ccd72019-07-23 15:54:41 -0700185 /** @hide */
186 @Retention(RetentionPolicy.SOURCE)
sangyun35f23f82023-07-18 01:37:53 +0900187 @IntDef(prefix = {"ROAMING_NOTIFICATION_REASON_"},
188 value = {
189 ROAMING_NOTIFICATION_REASON_DATA_SETTING_CHANGED,
190 ROAMING_NOTIFICATION_REASON_DATA_ROAMING_SETTING_CHANGED,
191 ROAMING_NOTIFICATION_REASON_CARRIER_CONFIG_CHANGED,
192 ROAMING_NOTIFICATION_REASON_SERVICE_STATE_CHANGED,
sangyund2cfeaa2024-03-31 12:20:40 +0900193 ROAMING_NOTIFICATION_REASON_DEFAULT_DATA_SUBS_CHANGED,
194 ROAMING_NOTIFICATION_REASON_DISCONNECTED_SINGLE_NETWORK})
sangyun35f23f82023-07-18 01:37:53 +0900195 public @interface RoamingNotificationReason {}
196 private static final int ROAMING_NOTIFICATION_REASON_DATA_SETTING_CHANGED = 0;
197 private static final int ROAMING_NOTIFICATION_REASON_DATA_ROAMING_SETTING_CHANGED = 1;
198 private static final int ROAMING_NOTIFICATION_REASON_CARRIER_CONFIG_CHANGED = 2;
199 private static final int ROAMING_NOTIFICATION_REASON_SERVICE_STATE_CHANGED = 3;
200 private static final int ROAMING_NOTIFICATION_REASON_DEFAULT_DATA_SUBS_CHANGED = 4;
sangyund2cfeaa2024-03-31 12:20:40 +0900201 private static final int ROAMING_NOTIFICATION_REASON_DISCONNECTED_SINGLE_NETWORK = 5;
sangyun35f23f82023-07-18 01:37:53 +0900202
203 /** @hide */
204 @Retention(RetentionPolicy.SOURCE)
Jordan Liuff2ccd72019-07-23 15:54:41 -0700205 @IntDef(prefix = {"ROAMING_NOTIFICATION_"},
206 value = {
207 ROAMING_NOTIFICATION_NO_NOTIFICATION,
208 ROAMING_NOTIFICATION_CONNECTED,
209 ROAMING_NOTIFICATION_DISCONNECTED})
210 public @interface RoamingNotification {}
211
212 private static final int ROAMING_NOTIFICATION_NO_NOTIFICATION = 0;
213 private static final int ROAMING_NOTIFICATION_CONNECTED = 1;
214 private static final int ROAMING_NOTIFICATION_DISCONNECTED = 2;
215
216 @RoamingNotification
sangyun35f23f82023-07-18 01:37:53 +0900217 private int mCurrentRoamingNotification = ROAMING_NOTIFICATION_NO_NOTIFICATION;
Jack Yu953f9352017-05-18 14:41:06 -0700218
sangyun35f23f82023-07-18 01:37:53 +0900219 /**
sangyund2cfeaa2024-03-31 12:20:40 +0900220 * If true, update roaming notifications after the Internet is completely disconnected. If
221 * carrier allows only a single data network, wait until the Internet connection is completely
222 * disconnected and then update the roaming notification once more to check if
223 * ONLY_ALLOWED_SINGLE_NETWORK disallow reason is disappeared.
224 */
225 private AtomicBoolean mWaitForInternetDisconnection = new AtomicBoolean(false);
226
227 /**
sangyun35f23f82023-07-18 01:37:53 +0900228 * Reasons that have already shown notification to prevent duplicate shows for the same reason.
229 */
230 private ArraySet<String> mShownNotificationReasons = new ArraySet<>();
Ling Ma317906d2022-12-05 15:58:14 -0800231
sangyun1c1918a2023-11-13 22:37:50 +0900232 // For reorganize_roaming_notification feature disabled.
233 @RoamingNotification
234 private int mPrevRoamingNotification = ROAMING_NOTIFICATION_NO_NOTIFICATION;
235
236 // For reorganize_roaming_notification feature disabled.
237 /** Operator numerics for which we've shown is-roaming notifications. **/
238 private ArraySet<String> mPrevRoamingOperatorNumerics = new ArraySet<>();
239
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700240 private WakeState mWakeState = WakeState.SLEEP;
241
242 private PowerManager mPowerManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700243 private PowerManager.WakeLock mWakeLock;
244 private PowerManager.WakeLock mPartialWakeLock;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700245 private KeyguardManager mKeyguardManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700246
Jack Yu1a2fc352017-07-14 17:14:37 -0700247 private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
248 private final LocalLog mDataRoamingNotifLog = new LocalLog(50);
249
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700250 // Broadcast receiver for various intent broadcasts (see onCreate())
251 private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver();
252
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -0700253 private final CarrierVvmPackageInstalledReceiver mCarrierVvmPackageInstalledReceiver =
254 new CarrierVvmPackageInstalledReceiver();
255
joonhunshin051ab232024-02-06 02:21:46 +0000256 private SettingsObserver mSettingsObserver;
Siim Sammul182d61b2021-05-04 16:01:42 +0100257 private BinderCallsStats.SettingsObserver mBinderCallsSettingsObserver;
Jack Yu1a2fc352017-07-14 17:14:37 -0700258
Sarah Chin072ffb22022-05-03 17:58:59 -0700259 // Mapping of phone ID to the associated TelephonyCallback. These should be registered without
260 // fine or coarse location since we only use ServiceState for
261 private PhoneAppCallback[] mTelephonyCallbacks;
262
joonhunshin051ab232024-02-06 02:21:46 +0000263 private FeatureFlags mFeatureFlags = new FeatureFlagsImpl();
sangyun15019e02023-11-13 21:50:15 +0900264
Sarah Chin072ffb22022-05-03 17:58:59 -0700265 private class PhoneAppCallback extends TelephonyCallback implements
sangyund2cfeaa2024-03-31 12:20:40 +0900266 TelephonyCallback.ServiceStateListener,
267 TelephonyCallback.DataConnectionStateListener {
Sarah Chin072ffb22022-05-03 17:58:59 -0700268 private final int mSubId;
269
270 PhoneAppCallback(int subId) {
271 mSubId = subId;
272 }
273
274 @Override
275 public void onServiceStateChanged(ServiceState serviceState) {
276 // Note when registering that we should be registering with INCLUDE_LOCATION_DATA_NONE.
277 // PhoneGlobals only uses the state and roaming status, which does not require location.
278 handleServiceStateChanged(serviceState, mSubId);
279 }
280
sangyund2cfeaa2024-03-31 12:20:40 +0900281 @Override
282 public void onDataConnectionStateChanged(int state, int networkType) {
283 if (mSubId == mDefaultDataSubId && state == TelephonyManager.DATA_DISCONNECTED) {
284 // onDataConnectionStateChanged is an event about the state of exact DataNetwork,
285 // but since the DataNetwork of internet may not have been completely removed from
286 // the DataNetworkController list, The post handler event expects the internet data
287 // network to be completely removed from the DataNetworkController list.
288 mHandler.post(() -> {
289 if (mWaitForInternetDisconnection.compareAndSet(true, false)) {
290 Log.d(LOG_TAG, "onDisconnectedInternetDataNetwork.");
291 updateDataRoamingStatus(
292 ROAMING_NOTIFICATION_REASON_DISCONNECTED_SINGLE_NETWORK);
293 }
294 });
295 }
296 }
297
Sarah Chin072ffb22022-05-03 17:58:59 -0700298 public int getSubId() {
299 return mSubId;
300 }
301 }
302
Nazish Tabassum160d2112019-12-23 17:31:33 +0530303 private static class EventSimStateChangedBag {
304 final int mPhoneId;
305 final String mIccStatus;
306
307 EventSimStateChangedBag(int phoneId, String iccStatus) {
308 mPhoneId = phoneId;
309 mIccStatus = iccStatus;
310 }
311 }
312
Jordan Liu06bdef12021-03-24 17:25:46 -0700313 // Some carrier config settings disable the network lock screen, so we call handleSimLock
314 // when either SIM_LOCK or CARRIER_CONFIG changes so that no matter which one happens first,
315 // we still do the right thing
316 private void handleSimLock(int subType, Phone phone) {
317 PersistableBundle cc = getCarrierConfigForSubId(phone.getSubId());
318 if (!CarrierConfigManager.isConfigForIdentifiedCarrier(cc)) {
319 // If we only have the default carrier config just return, to avoid popping up the
320 // the SIM lock screen when it's disabled by the carrier.
321 Log.i(LOG_TAG, "Not showing 'SIM network unlock' screen. Carrier config not loaded");
322 return;
323 }
324 if (cc.getBoolean(CarrierConfigManager.KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL)) {
325 // Some products don't have the concept of a "SIM network lock"
326 Log.i(LOG_TAG, "Not showing 'SIM network unlock' screen. Disabled by carrier config");
327 return;
328 }
329
330 // if passed in subType is unknown, retrieve it here.
331 if (subType == -1) {
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +0000332 final UiccPort uiccPort = phone.getUiccPort();
333 if (uiccPort == null) {
Jordan Liu06bdef12021-03-24 17:25:46 -0700334 Log.e(LOG_TAG,
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +0000335 "handleSimLock: uiccPort for phone " + phone.getPhoneId() + " is null");
Jordan Liu06bdef12021-03-24 17:25:46 -0700336 return;
337 }
Muralidhar Reddy472c2ae2021-09-29 19:38:40 +0000338 final UiccProfile uiccProfile = uiccPort.getUiccProfile();
Jordan Liu06bdef12021-03-24 17:25:46 -0700339 if (uiccProfile == null) {
340 Log.e(LOG_TAG,
341 "handleSimLock: uiccProfile for phone " + phone.getPhoneId() + " is null");
342 return;
343 }
344 subType = uiccProfile.getApplication(
345 uiccProfile.mCurrentAppType).getPersoSubState().ordinal();
346 }
347 // Normal case: show the "SIM network unlock" PIN entry screen.
348 // The user won't be able to do anything else until
349 // they enter a valid SIM network PIN.
350 Log.i(LOG_TAG, "show sim depersonal panel");
351 IccNetworkDepersonalizationPanel.showDialog(phone, subType);
352 }
353
354 private boolean isSimLocked(Phone phone) {
355 TelephonyManager tm = getSystemService(TelephonyManager.class);
356 return tm.createForSubscriptionId(phone.getSubId()).getSimState()
357 == TelephonyManager.SIM_STATE_NETWORK_LOCKED;
358 }
359
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700360 Handler mHandler = new Handler() {
361 @Override
362 public void handleMessage(Message msg) {
363 PhoneConstants.State phoneState;
Jack Yu1a2fc352017-07-14 17:14:37 -0700364 if (VDBG) Log.v(LOG_TAG, "event=" + msg.what);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700365 switch (msg.what) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700366 // TODO: This event should be handled by the lock screen, just
367 // like the "SIM missing" and "Sim locked" cases (bug 1804111).
368 case EVENT_SIM_NETWORK_LOCKED:
Jordan Liu06bdef12021-03-24 17:25:46 -0700369 int subType = (Integer) ((AsyncResult) msg.obj).result;
370 Phone phone = (Phone) ((AsyncResult) msg.obj).userObj;
371 handleSimLock(subType, phone);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700372 break;
373
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700374 case EVENT_DATA_ROAMING_DISCONNECTED:
Nagendra Prasad Nagarle Basavarajuf668eda2024-02-15 15:02:57 +0000375 if (SubscriptionManagerService.getInstance()
376 .isEsimBootStrapProvisioningActiveForSubId(msg.arg1)) {
377 Log.i(LOG_TAG,
378 "skip notification/warnings during esim bootstrap activation");
379 } else {
380 notificationMgr.showDataRoamingNotification(msg.arg1, false);
381 }
Jordan Liuff2ccd72019-07-23 15:54:41 -0700382 break;
383
384 case EVENT_DATA_ROAMING_CONNECTED:
Nagendra Prasad Nagarle Basavarajuf668eda2024-02-15 15:02:57 +0000385 if (SubscriptionManagerService.getInstance()
386 .isEsimBootStrapProvisioningActiveForSubId(msg.arg1)) {
387 Log.i(LOG_TAG,
388 "skip notification/warnings during esim bootstrap activation");
389 } else {
390 notificationMgr.showDataRoamingNotification(msg.arg1, true);
391 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700392 break;
393
394 case EVENT_DATA_ROAMING_OK:
Jordan Liuff2ccd72019-07-23 15:54:41 -0700395 notificationMgr.hideDataRoamingNotification();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700396 break;
397
398 case MMI_COMPLETE:
399 onMMIComplete((AsyncResult) msg.obj);
400 break;
401
402 case MMI_CANCEL:
Stuart Scottdcf40a92014-12-09 10:45:01 -0800403 PhoneUtils.cancelMmiCode(mCM.getFgPhone());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700404 break;
405
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700406 case EVENT_SIM_STATE_CHANGED:
Nazish Tabassum160d2112019-12-23 17:31:33 +0530407 EventSimStateChangedBag bag = (EventSimStateChangedBag)msg.obj;
Sarah Chin010884c2023-06-14 15:55:08 -0700408 // Dismiss the "No services" notification if the SIM is removed.
409 if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(bag.mIccStatus)) {
410 notificationMgr.dismissNetworkSelectionNotificationForInactiveSubId();
411 }
412
413 // Marks the event where the SIM goes into ready state.
414 // Right now, this is only used for the PUK-unlocking process.
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700415 if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(bag.mIccStatus)
Nazish Tabassum59126a92020-07-03 21:44:49 +0530416 || IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(bag.mIccStatus)
417 || IccCardConstants.INTENT_VALUE_ICC_NOT_READY.equals(bag.mIccStatus)
418 || IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(bag.mIccStatus)) {
Sarah Chin010884c2023-06-14 15:55:08 -0700419 // When the right event is triggered and there are UI objects in the
420 // foreground, we close them to display the lock panel.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700421 if (mPUKEntryActivity != null) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700422 Log.i(LOG_TAG, "Dismiss puk entry activity");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700423 mPUKEntryActivity.finish();
424 mPUKEntryActivity = null;
425 }
426 if (mPUKEntryProgressDialog != null) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700427 Log.i(LOG_TAG, "Dismiss puk progress dialog");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700428 mPUKEntryProgressDialog.dismiss();
429 mPUKEntryProgressDialog = null;
430 }
Nazish Tabassum59126a92020-07-03 21:44:49 +0530431 Log.i(LOG_TAG, "Dismissing depersonal panel" + (bag.mIccStatus));
Nazish Tabassum160d2112019-12-23 17:31:33 +0530432 IccNetworkDepersonalizationPanel.dialogDismiss(bag.mPhoneId);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700433 }
434 break;
435
436 case EVENT_UNSOL_CDMA_INFO_RECORD:
437 //TODO: handle message here;
438 break;
Jack Yu1a2fc352017-07-14 17:14:37 -0700439 case EVENT_DATA_ROAMING_SETTINGS_CHANGED:
sangyun1c1918a2023-11-13 22:37:50 +0900440 if (mFeatureFlags.reorganizeRoamingNotification()) {
441 updateDataRoamingStatus(
442 ROAMING_NOTIFICATION_REASON_DATA_ROAMING_SETTING_CHANGED);
443 } else {
444 updateDataRoamingStatusForFeatureDisabled(null);
445 }
sangyun35f23f82023-07-18 01:37:53 +0900446 break;
Jack Yu1a2fc352017-07-14 17:14:37 -0700447 case EVENT_MOBILE_DATA_SETTINGS_CHANGED:
sangyun1c1918a2023-11-13 22:37:50 +0900448 if (mFeatureFlags.reorganizeRoamingNotification()) {
449 updateDataRoamingStatus(ROAMING_NOTIFICATION_REASON_DATA_SETTING_CHANGED);
450 } else {
451 updateDataRoamingStatusForFeatureDisabled(null);
452 }
Jack Yu1a2fc352017-07-14 17:14:37 -0700453 break;
Lei Liu863eac02020-06-24 20:12:55 +0800454 case EVENT_CARRIER_CONFIG_CHANGED:
455 int subId = (Integer) msg.obj;
456 // The voicemail number could be overridden by carrier config, so need to
457 // refresh the message waiting (voicemail) indicator.
458 refreshMwiIndicator(subId);
Jordan Liu06bdef12021-03-24 17:25:46 -0700459 phone = getPhone(subId);
Sarah Chin072ffb22022-05-03 17:58:59 -0700460 if (phone != null) {
461 if (isSimLocked(phone)) {
462 // pass in subType=-1 so handleSimLock can find the actual subType if
463 // needed. This is safe as valid values for subType are >= 0
464 handleSimLock(-1, phone);
465 }
466 TelephonyManager tm = getSystemService(TelephonyManager.class);
467 PhoneAppCallback callback = mTelephonyCallbacks[phone.getPhoneId()];
468 // TODO: We may need to figure out a way to unregister if subId is invalid
469 tm.createForSubscriptionId(callback.getSubId())
470 .unregisterTelephonyCallback(callback);
471 callback = new PhoneAppCallback(subId);
472 tm.createForSubscriptionId(subId).registerTelephonyCallback(
Ling Ma317906d2022-12-05 15:58:14 -0800473 TelephonyManager.INCLUDE_LOCATION_DATA_COARSE, mHandler::post,
Sarah Chin072ffb22022-05-03 17:58:59 -0700474 callback);
475 mTelephonyCallbacks[phone.getPhoneId()] = callback;
476 }
477 break;
478 case EVENT_MULTI_SIM_CONFIG_CHANGED:
479 int activeModems = (int) ((AsyncResult) msg.obj).result;
480 TelephonyManager tm = getSystemService(TelephonyManager.class);
481 // Unregister all previous callbacks
482 for (int phoneId = 0; phoneId < mTelephonyCallbacks.length; phoneId++) {
483 PhoneAppCallback callback = mTelephonyCallbacks[phoneId];
484 if (callback != null) {
485 tm.createForSubscriptionId(callback.getSubId())
486 .unregisterTelephonyCallback(callback);
487 mTelephonyCallbacks[phoneId] = null;
488 }
489 }
490 // Register callbacks for all active modems
491 for (int phoneId = 0; phoneId < activeModems; phoneId++) {
492 int sub = PhoneFactory.getPhone(phoneId).getSubId();
493 PhoneAppCallback callback = new PhoneAppCallback(sub);
494 tm.createForSubscriptionId(sub).registerTelephonyCallback(
495 TelephonyManager.INCLUDE_LOCATION_DATA_NONE, mHandler::post,
496 callback);
497 mTelephonyCallbacks[phoneId] = callback;
Jordan Liu06bdef12021-03-24 17:25:46 -0700498 }
Lei Liu863eac02020-06-24 20:12:55 +0800499 break;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700500 }
501 }
502 };
503
504 public PhoneGlobals(Context context) {
505 super(context);
506 sMe = this;
joonhunshin051ab232024-02-06 02:21:46 +0000507 if (mFeatureFlags.enforceTelephonyFeatureMappingForPublicApis()) {
508 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
509 mSettingsObserver = new SettingsObserver(context, mHandler);
510 }
511 } else {
512 mSettingsObserver = new SettingsObserver(context, mHandler);
513 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700514 }
515
516 public void onCreate() {
517 if (VDBG) Log.v(LOG_TAG, "onCreate()...");
518
519 ContentResolver resolver = getContentResolver();
520
joonhunshin051ab232024-02-06 02:21:46 +0000521 if (mFeatureFlags.enforceTelephonyFeatureMappingForPublicApis()) {
522 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
523 Log.v(LOG_TAG, "onCreate()... but not defined FEATURE_TELEPHONY");
524 return;
525 }
526 }
527
Hall Liuaa4211e2021-01-20 15:43:39 -0800528 // Initialize the shim from frameworks/opt/telephony into packages/services/Telephony.
529 TelephonyLocalConnection.setInstance(new LocalConnectionImpl(this));
530
Sarah Chin072ffb22022-05-03 17:58:59 -0700531 TelephonyManager tm = getSystemService(TelephonyManager.class);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700532 // Cache the "voice capable" flag.
533 // This flag currently comes from a resource (which is
534 // overrideable on a per-product basis):
Sarah Chin072ffb22022-05-03 17:58:59 -0700535 sVoiceCapable = tm.isVoiceCapable();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700536 // ...but this might eventually become a PackageManager "system
537 // feature" instead, in which case we'd do something like:
538 // sVoiceCapable =
539 // getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_VOICE_CALLS);
540
Stuart Scottdcf40a92014-12-09 10:45:01 -0800541 if (mCM == null) {
Nathan Haroldf9df6ea2019-03-08 11:54:22 -0800542 // Initialize AnomalyReporter early so that it can be used
543 AnomalyReporter.initialize(this);
Nathan Harold0db5c5e2019-01-22 20:18:56 -0800544
Youming Ye47a6adc2018-11-19 15:33:36 -0800545 // Inject telephony component factory if configured using other jars.
546 XmlResourceParser parser = getResources().getXml(R.xml.telephony_injection);
547 TelephonyComponentFactory.getInstance().injectTheComponentFactory(parser);
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000548
549 // Create DomainSelectionResolver always, but it MUST be initialized only when
550 // the device supports AOSP domain selection architecture and
551 // has new IRadio that supports its related HAL APIs.
Hwangoo Parkbf3968c2024-01-19 07:49:22 +0000552 String dssComponentName = getResources().getString(
553 R.string.config_domain_selection_service_component_name);
554 DomainSelectionResolver.make(this, dssComponentName);
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000555
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700556 // Initialize the telephony framework
sangyun15019e02023-11-13 21:50:15 +0900557 PhoneFactory.makeDefaultPhones(this, mFeatureFlags);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700558
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000559 // Initialize the DomainSelectionResolver after creating the Phone instance
560 // to check the Radio HAL version.
561 if (DomainSelectionResolver.getInstance().isDomainSelectionSupported()) {
Hwangoo Parkbf3968c2024-01-19 07:49:22 +0000562 DomainSelectionResolver.getInstance().initialize();
Daniel Bantab26e96f2022-10-19 23:25:35 +0000563 // Initialize EmergencyStateTracker if domain selection is supported
564 boolean isSuplDdsSwitchRequiredForEmergencyCall = getResources()
565 .getBoolean(R.bool.config_gnss_supl_requires_default_data_for_emergency);
566 EmergencyStateTracker.make(this, isSuplDdsSwitchRequiredForEmergencyCall);
Hwangoo Parkba21cf22022-11-30 14:34:04 +0000567 }
568
Brad Ebinger05f52c22019-12-05 13:03:21 -0800569 // Only bring up ImsResolver if the device supports having an IMS stack.
570 if (getPackageManager().hasSystemFeature(
571 PackageManager.FEATURE_TELEPHONY_IMS)) {
572 // Get the package name of the default IMS implementation.
573 String defaultImsMmtelPackage = getResources().getString(
574 R.string.config_ims_mmtel_package);
575 String defaultImsRcsPackage = getResources().getString(
576 R.string.config_ims_rcs_package);
Brad Ebingerd1947d82021-05-17 20:54:49 +0000577 ImsResolver.make(this, defaultImsMmtelPackage,
Brad Ebingere3ae65a2020-09-11 12:45:11 -0700578 defaultImsRcsPackage, PhoneFactory.getPhones().length,
joonhunshin42441672024-04-26 01:26:14 +0000579 new ImsFeatureBinderRepository(), mFeatureFlags);
Brad Ebingerd1947d82021-05-17 20:54:49 +0000580 ImsResolver.getInstance().initialize();
Tyler Gunn92479152021-01-20 16:30:10 -0800581
582 // With the IMS phone created, load static config.xml values from the phone process
583 // so that it can be provided to the ImsPhoneCallTracker.
584 for (Phone p : PhoneFactory.getPhones()) {
585 Phone imsPhone = p.getImsPhone();
586 if (imsPhone != null && imsPhone instanceof ImsPhone) {
587 ImsPhone theImsPhone = (ImsPhone) imsPhone;
588 if (theImsPhone.getCallTracker() instanceof ImsPhoneCallTracker) {
589 ImsPhoneCallTracker ict = (ImsPhoneCallTracker)
590 theImsPhone.getCallTracker();
591
592 ImsPhoneCallTracker.Config config = new ImsPhoneCallTracker.Config();
593 config.isD2DCommunicationSupported = getResources().getBoolean(
594 R.bool.config_use_device_to_device_communication);
595 ict.setConfig(config);
596 }
597 }
598 }
Hui Wang068ab862020-10-31 05:12:53 +0000599 RcsProvisioningMonitor.make(this);
Brad Ebinger05f52c22019-12-05 13:03:21 -0800600 }
601
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700602 // Start TelephonyDebugService After the default phone is created.
603 Intent intent = new Intent(this, TelephonyDebugService.class);
604 startService(intent);
605
606 mCM = CallManager.getInstance();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700607
608 // Create the NotificationMgr singleton, which is used to display
609 // status bar icons and control other status bar behavior.
610 notificationMgr = NotificationMgr.init(this);
611
Aishwarya Mallampati481aeee2023-02-17 21:32:22 +0000612 // Create the SatelliteController singleton, which acts as a backend service for
613 // {@link android.telephony.satellite.SatelliteManager}.
sangyun15019e02023-11-13 21:50:15 +0900614 SatelliteController.make(this, mFeatureFlags);
Sarah Chin5f57c582023-02-14 04:16:10 -0800615
Anthony Lee03ebdfc2015-07-27 08:12:02 -0700616 // Create an instance of CdmaPhoneCallState and initialize it to IDLE
617 cdmaPhoneCallState = new CdmaPhoneCallState();
618 cdmaPhoneCallState.CdmaPhoneCallStateInit();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700619
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700620 // before registering for phone state changes
621 mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
622 mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, LOG_TAG);
623 // lock used to keep the processor awake, when we don't care for the display.
624 mPartialWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
625 | PowerManager.ON_AFTER_RELEASE, LOG_TAG);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700626
627 mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
628
sangyun15019e02023-11-13 21:50:15 +0900629 phoneMgr = PhoneInterfaceManager.init(this, mFeatureFlags);
Santos Cordon406c0342013-08-28 00:07:47 -0700630
joonhunshin2c33ed92023-12-12 14:29:23 +0000631 imsRcsController = ImsRcsController.init(this, mFeatureFlags);
James.cf Linaf3183c2019-10-24 00:59:00 +0800632
joonhunshin21a86812023-12-10 08:21:25 +0000633 configLoader = CarrierConfigLoader.init(this, mFeatureFlags);
Brad Ebinger6c53e7f2023-01-27 16:26:44 -0800634
James.cf Linc9f35a42020-01-15 02:35:22 +0800635 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS)) {
Hunsuk Choi3b742d62021-10-25 19:48:34 +0000636 mImsStateCallbackController =
637 ImsStateCallbackController.make(this, PhoneFactory.getPhones().length);
Brad Ebingera68a4972020-01-30 17:31:23 -0800638 mTelephonyRcsService = new TelephonyRcsService(this,
joonhunshind9dfe8d2024-02-05 09:08:06 +0000639 PhoneFactory.getPhones().length, mFeatureFlags);
Brad Ebingera68a4972020-01-30 17:31:23 -0800640 mTelephonyRcsService.initialize();
James.cf Linc9f35a42020-01-15 02:35:22 +0800641 imsRcsController.setRcsService(mTelephonyRcsService);
joonhunshincffb7fc2021-11-28 07:32:01 +0000642 mImsProvisioningController =
joonhunshin711a8872024-03-19 10:04:08 +0000643 ImsProvisioningController.make(this, PhoneFactory.getPhones().length,
644 mFeatureFlags);
James.cf Linc9f35a42020-01-15 02:35:22 +0800645 }
646
Jack Yu1a2fc352017-07-14 17:14:37 -0700647 // Create the CallNotifier singleton, which handles
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700648 // asynchronous events from the telephony layer (like
649 // launching the incoming-call UI when an incoming call comes
650 // in.)
Brad Ebingera9c6b6d2016-01-07 17:24:16 -0800651 notifier = CallNotifier.init(this);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700652
Stuart Scottdcf40a92014-12-09 10:45:01 -0800653 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700654
655 // register for MMI/USSD
656 mCM.registerForMmiComplete(mHandler, MMI_COMPLETE, null);
657
Qiong Liucc3fe812019-09-23 15:25:44 +0800658 // Initialize cell status using current airplane mode.
Taesu Lee62f826d2020-08-10 16:01:18 +0900659 handleAirplaneModeChange(
660 Settings.Global.getInt(
661 getContentResolver(),
662 Settings.Global.AIRPLANE_MODE_ON,
663 AIRPLANE_OFF)
664 == AIRPLANE_ON);
Qiong Liucc3fe812019-09-23 15:25:44 +0800665
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700666 // Register for misc other intent broadcasts.
667 IntentFilter intentFilter =
668 new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700669 intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
670 intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700671 intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
Jack Yu1a2fc352017-07-14 17:14:37 -0700672 intentFilter.addAction(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
673 intentFilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700674 registerReceiver(mReceiver, intentFilter);
Jack Yuec144222023-12-13 16:03:03 -0800675 int defaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
676 if (SubscriptionManager.isValidSubscriptionId(defaultDataSubId)) {
677 if (VDBG) {
678 Log.v(LOG_TAG, "Loaded initial default data sub: " + defaultDataSubId);
sangyun15019e02023-11-13 21:50:15 +0900679 }
Jack Yuec144222023-12-13 16:03:03 -0800680 mDefaultDataSubId = defaultDataSubId;
681 registerSettingsObserver();
682 updateDataRoamingStatus(ROAMING_NOTIFICATION_REASON_DEFAULT_DATA_SUBS_CHANGED);
sangyundce559b2023-09-11 10:25:55 +0900683 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700684
Sarah Chin072ffb22022-05-03 17:58:59 -0700685 PhoneConfigurationManager.registerForMultiSimConfigChange(
686 mHandler, EVENT_MULTI_SIM_CONFIG_CHANGED, null);
687
688 mTelephonyCallbacks = new PhoneAppCallback[tm.getSupportedModemCount()];
Fangyuan Li7f5c2752022-06-29 18:02:31 +0800689 if (tm.getSupportedModemCount() > 0) {
690 for (Phone phone : PhoneFactory.getPhones()) {
691 int subId = phone.getSubId();
692 PhoneAppCallback callback = new PhoneAppCallback(subId);
693 tm.createForSubscriptionId(subId).registerTelephonyCallback(
694 TelephonyManager.INCLUDE_LOCATION_DATA_NONE, mHandler::post, callback);
695 mTelephonyCallbacks[phone.getPhoneId()] = callback;
696 }
Sarah Chin072ffb22022-05-03 17:58:59 -0700697 }
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -0700698 mCarrierVvmPackageInstalledReceiver.register(this);
699
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700700 //set the default values for the preferences in the phone.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700701 PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700702 }
703
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700704 // XXX pre-load the SimProvider so that it's ready
705 resolver.getType(Uri.parse("content://icc/adn"));
706
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700707 // TODO: Register for Cdma Information Records
708 // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null);
709
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700710 // Read HAC settings and configure audio hardware
711 if (getResources().getBoolean(R.bool.hac_enabled)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800712 int hac = android.provider.Settings.System.getInt(
713 getContentResolver(),
714 android.provider.Settings.System.HEARING_AID,
715 0);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700716 AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
Jordan Liuf71aeef2019-08-21 11:46:09 -0700717 audioManager.setParameters(
718 SettingsConstants.HAC_KEY + "=" + (hac == SettingsConstants.HAC_ENABLED
719 ? SettingsConstants.HAC_VAL_ON : SettingsConstants.HAC_VAL_OFF));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700720 }
Siim Sammul182d61b2021-05-04 16:01:42 +0100721
722 // Start tracking Binder latency for the phone process.
723 mBinderCallsSettingsObserver = new BinderCallsStats.SettingsObserver(
724 getApplicationContext(),
Siim Sammula6950092021-06-22 17:14:03 +0100725 new BinderCallsStats(
726 new BinderCallsStats.Injector(),
727 com.android.internal.os.BinderLatencyProto.Dims.TELEPHONY));
Santos Cordonff506f52013-11-21 19:13:19 -0800728 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700729
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700730 /**
731 * Returns the singleton instance of the PhoneApp.
732 */
Sailesh Nepal1eaf22b2014-02-22 17:00:49 -0800733 public static PhoneGlobals getInstance() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700734 if (sMe == null) {
735 throw new IllegalStateException("No PhoneGlobals here!");
736 }
737 return sMe;
738 }
739
740 /**
Stuart Scottdcf40a92014-12-09 10:45:01 -0800741 * Returns the default phone.
742 *
Andrew Lee385019f2014-11-24 14:19:50 -0800743 * WARNING: This method should be used carefully, now that there may be multiple phones.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700744 */
Andrew Lee83383e42014-10-31 12:42:28 -0700745 public static Phone getPhone() {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800746 return PhoneFactory.getDefaultPhone();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700747 }
748
Andrew Lee2fcb6c32014-12-04 14:52:35 -0800749 public static Phone getPhone(int subId) {
750 return PhoneFactory.getPhone(SubscriptionManager.getPhoneId(subId));
Andrew Lee385019f2014-11-24 14:19:50 -0800751 }
752
Santos Cordonde10b752013-09-19 04:11:33 -0700753 /* package */ CallManager getCallManager() {
754 return mCM;
755 }
756
Chris Manton4e9fa912015-06-19 11:26:57 -0700757 public PersistableBundle getCarrierConfig() {
Shishir Agrawald3480e02016-01-25 13:05:49 -0800758 return getCarrierConfigForSubId(SubscriptionManager.getDefaultSubscriptionId());
Jonathan Basseri89b0ab42015-05-01 10:52:40 -0700759 }
760
Chris Manton4e9fa912015-06-19 11:26:57 -0700761 public PersistableBundle getCarrierConfigForSubId(int subId) {
Philip P. Moltmann0079aae2020-03-05 16:24:02 -0800762 return configLoader.getConfigForSubIdWithFeature(subId, getOpPackageName(),
763 getAttributionTag());
Junda Liu605148f2015-04-28 15:23:40 -0700764 }
765
Jack Yu1a2fc352017-07-14 17:14:37 -0700766 private void registerSettingsObserver() {
767 mSettingsObserver.unobserve();
768 String dataRoamingSetting = Settings.Global.DATA_ROAMING;
769 String mobileDataSetting = Settings.Global.MOBILE_DATA;
770 if (TelephonyManager.getDefault().getSimCount() > 1) {
771 int subId = mDefaultDataSubId;
772 if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
773 dataRoamingSetting += subId;
774 mobileDataSetting += subId;
775 }
776 }
777
778 // Listen for user data roaming setting changed event
779 mSettingsObserver.observe(Settings.Global.getUriFor(dataRoamingSetting),
780 EVENT_DATA_ROAMING_SETTINGS_CHANGED);
781
782 // Listen for mobile data setting changed event
783 mSettingsObserver.observe(Settings.Global.getUriFor(mobileDataSetting),
784 EVENT_MOBILE_DATA_SETTINGS_CHANGED);
785 }
786
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700787 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700788 * Sets the activity responsible for un-PUK-blocking the device
789 * so that we may close it when we receive a positive result.
790 * mPUKEntryActivity is also used to indicate to the device that
791 * we are trying to un-PUK-lock the phone. In other words, iff
792 * it is NOT null, then we are trying to unlock and waiting for
793 * the SIM to move to READY state.
794 *
795 * @param activity is the activity to close when PUK has
796 * finished unlocking. Can be set to null to indicate the unlock
797 * or SIM READYing process is over.
798 */
799 void setPukEntryActivity(Activity activity) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700800 Log.i(LOG_TAG, "setPukEntryActivity - set to " + (activity == null ? "null" : "activity"));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700801 mPUKEntryActivity = activity;
802 }
803
804 Activity getPUKEntryActivity() {
805 return mPUKEntryActivity;
806 }
807
808 /**
809 * Sets the dialog responsible for notifying the user of un-PUK-
810 * blocking - SIM READYing progress, so that we may dismiss it
811 * when we receive a positive result.
812 *
813 * @param dialog indicates the progress dialog informing the user
814 * of the state of the device. Dismissed upon completion of
815 * READYing process
816 */
817 void setPukEntryProgressDialog(ProgressDialog dialog) {
Tyler Gunn3fc09c02020-05-08 16:35:55 -0700818 Log.i(LOG_TAG, "setPukEntryProgressDialog - set to "
819 + (dialog == null ? "null" : "activity"));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700820 mPUKEntryProgressDialog = dialog;
821 }
822
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700823 KeyguardManager getKeyguardManager() {
824 return mKeyguardManager;
825 }
826
827 private void onMMIComplete(AsyncResult r) {
828 if (VDBG) Log.d(LOG_TAG, "onMMIComplete()...");
829 MmiCode mmiCode = (MmiCode) r.result;
Stuart Scottdcf40a92014-12-09 10:45:01 -0800830 PhoneUtils.displayMMIComplete(mmiCode.getPhone(), getInstance(), mmiCode, null, null);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700831 }
832
fionaxu80126972017-02-01 17:01:26 -0800833 private void initForNewRadioTechnology() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700834 if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology...");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700835 notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700836 }
837
Taesu Lee62f826d2020-08-10 16:01:18 +0900838 private void handleAirplaneModeChange(boolean isAirplaneNewlyOn) {
Sarah Chin9ec6e1e2022-08-10 13:29:40 -0700839 Log.i(LOG_TAG, "handleAirplaneModeChange: isAirplaneNewlyOn=" + isAirplaneNewlyOn);
Taesu Lee62f826d2020-08-10 16:01:18 +0900840 int cellState =
841 Settings.Global.getInt(
842 getContentResolver(), Settings.Global.CELL_ON, PhoneConstants.CELL_ON_FLAG);
Chris Mantona09f3632016-02-09 14:48:42 -0800843 switch (cellState) {
844 case PhoneConstants.CELL_OFF_FLAG:
Sarah Chin9ec6e1e2022-08-10 13:29:40 -0700845 // Airplane mode does not affect the cell radio if user has turned it off.
846 Log.i(LOG_TAG, "Ignore airplane mode change due to cell off.");
Chris Mantona09f3632016-02-09 14:48:42 -0800847 break;
848 case PhoneConstants.CELL_ON_FLAG:
Taesu Lee62f826d2020-08-10 16:01:18 +0900849 maybeTurnCellOff(isAirplaneNewlyOn);
Chris Mantona09f3632016-02-09 14:48:42 -0800850 break;
851 case PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG:
Taesu Lee62f826d2020-08-10 16:01:18 +0900852 maybeTurnCellOn(isAirplaneNewlyOn);
Chris Mantona09f3632016-02-09 14:48:42 -0800853 break;
854 }
Hall Liu7f56e1a2019-07-10 14:41:14 -0700855 for (Phone phone : PhoneFactory.getPhones()) {
856 phone.getServiceStateTracker().onAirplaneModeChanged(isAirplaneNewlyOn);
857 }
Chris Mantona09f3632016-02-09 14:48:42 -0800858 }
859
860 /*
861 * Returns true if the radio must be turned off when entering airplane mode.
862 */
Taesu Lee62f826d2020-08-10 16:01:18 +0900863 private boolean isCellOffInAirplaneMode() {
864 String airplaneModeRadios =
865 Settings.Global.getString(
866 getContentResolver(), Settings.Global.AIRPLANE_MODE_RADIOS);
Chris Mantona09f3632016-02-09 14:48:42 -0800867 return airplaneModeRadios == null
868 || airplaneModeRadios.contains(Settings.Global.RADIO_CELL);
869 }
870
Taesu Lee62f826d2020-08-10 16:01:18 +0900871 private void setRadioPowerOff() {
Chris Mantona09f3632016-02-09 14:48:42 -0800872 Log.i(LOG_TAG, "Turning radio off - airplane");
Taesu Lee62f826d2020-08-10 16:01:18 +0900873 Settings.Global.putInt(
874 getContentResolver(),
875 Settings.Global.CELL_ON,
876 PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG);
Chris Mantona09f3632016-02-09 14:48:42 -0800877 Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT, 0);
Taesu Lee62f826d2020-08-10 16:01:18 +0900878 TelephonyProperties.airplane_mode_on(true); // true means int value 1
Chris Mantona09f3632016-02-09 14:48:42 -0800879 PhoneUtils.setRadioPower(false);
Ling Ma317906d2022-12-05 15:58:14 -0800880 clearCacheOnRadioOff();
881 }
882
883 /** Clear fields on power off radio **/
884 private void clearCacheOnRadioOff() {
885 // Re-show is-roaming notifications after APM mode
sangyun1c1918a2023-11-13 22:37:50 +0900886 if (mFeatureFlags.reorganizeRoamingNotification()) {
887 mShownNotificationReasons.clear();
888 } else {
889 mPrevRoamingOperatorNumerics.clear();
890 }
Chris Mantona09f3632016-02-09 14:48:42 -0800891 }
892
Taesu Lee62f826d2020-08-10 16:01:18 +0900893 private void setRadioPowerOn() {
Chris Mantona09f3632016-02-09 14:48:42 -0800894 Log.i(LOG_TAG, "Turning radio on - airplane");
Taesu Lee62f826d2020-08-10 16:01:18 +0900895 Settings.Global.putInt(
896 getContentResolver(), Settings.Global.CELL_ON, PhoneConstants.CELL_ON_FLAG);
897 Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT, 1);
Meng Wang61307622019-10-23 14:08:43 -0700898 TelephonyProperties.airplane_mode_on(false); // false means int value 0
Chris Mantona09f3632016-02-09 14:48:42 -0800899 PhoneUtils.setRadioPower(true);
900 }
901
Taesu Lee62f826d2020-08-10 16:01:18 +0900902 private void maybeTurnCellOff(boolean isAirplaneNewlyOn) {
Chris Mantona09f3632016-02-09 14:48:42 -0800903 if (isAirplaneNewlyOn) {
Santos Cordone18902f2016-03-22 17:16:04 -0700904 // If we are trying to turn off the radio, make sure there are no active
905 // emergency calls. If there are, switch airplane mode back to off.
Taesu Lee62f826d2020-08-10 16:01:18 +0900906 TelecomManager tm = (TelecomManager) getSystemService(TELECOM_SERVICE);
Tyler Gunn900d8fd2018-09-21 09:22:12 -0700907
908 if (tm != null && tm.isInEmergencyCall()) {
Santos Cordone18902f2016-03-22 17:16:04 -0700909 // Switch airplane mode back to off.
Jordan Liu0e819b12019-08-28 15:33:05 -0700910 ConnectivityManager cm =
Taesu Lee62f826d2020-08-10 16:01:18 +0900911 (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
Jordan Liu0e819b12019-08-28 15:33:05 -0700912 cm.setAirplaneMode(false);
Santos Cordone18902f2016-03-22 17:16:04 -0700913 Toast.makeText(this, R.string.radio_off_during_emergency_call, Toast.LENGTH_LONG)
914 .show();
915 Log.i(LOG_TAG, "Ignoring airplane mode: emergency call. Turning airplane off");
Taesu Lee62f826d2020-08-10 16:01:18 +0900916 } else if (isCellOffInAirplaneMode()) {
917 setRadioPowerOff();
Santos Cordone18902f2016-03-22 17:16:04 -0700918 } else {
Chris Mantona09f3632016-02-09 14:48:42 -0800919 Log.i(LOG_TAG, "Ignoring airplane mode: settings prevent cell radio power off");
Santos Cordone18902f2016-03-22 17:16:04 -0700920 }
Sarah Chin9ec6e1e2022-08-10 13:29:40 -0700921 } else {
922 Log.i(LOG_TAG, "Ignoring airplane mode: not newly on");
Chris Mantona09f3632016-02-09 14:48:42 -0800923 }
924 }
925
Taesu Lee62f826d2020-08-10 16:01:18 +0900926 private void maybeTurnCellOn(boolean isAirplaneNewlyOn) {
Chris Mantona09f3632016-02-09 14:48:42 -0800927 if (!isAirplaneNewlyOn) {
Taesu Lee62f826d2020-08-10 16:01:18 +0900928 setRadioPowerOn();
Sarah Chin9ec6e1e2022-08-10 13:29:40 -0700929 } else {
930 Log.i(LOG_TAG, "Ignoring airplane mode off: radio is already on.");
Santos Cordone18902f2016-03-22 17:16:04 -0700931 }
932 }
933
Santos Cordon593ab382013-08-06 21:58:23 -0700934 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700935 * Receiver for misc intent broadcasts the Phone app cares about.
936 */
937 private class PhoneAppBroadcastReceiver extends BroadcastReceiver {
938 @Override
939 public void onReceive(Context context, Intent intent) {
940 String action = intent.getAction();
941 if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
Taesu Lee3dc572b2020-08-07 18:16:22 +0900942 boolean airplaneMode = intent.getBooleanExtra("state", false);
Taesu Lee62f826d2020-08-10 16:01:18 +0900943 handleAirplaneModeChange(airplaneMode);
Amit Mahajanf5d92c82018-11-02 17:44:40 -0700944 } else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
945 // re-register as it may be a new IccCard
946 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY,
947 SubscriptionManager.INVALID_PHONE_INDEX);
948 if (SubscriptionManager.isValidPhoneId(phoneId)) {
949 PhoneUtils.unregisterIccStatus(mHandler, phoneId);
950 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED, phoneId);
951 }
Nazish Tabassum160d2112019-12-23 17:31:33 +0530952 String iccStatus = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
953 mHandler.sendMessage(mHandler.obtainMessage(EVENT_SIM_STATE_CHANGED,
954 new EventSimStateChangedBag(phoneId, iccStatus)));
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700955 } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) {
956 String newPhone = intent.getStringExtra(PhoneConstants.PHONE_NAME_KEY);
fionaxu80126972017-02-01 17:01:26 -0800957 Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active.");
958 initForNewRadioTechnology();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700959 } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530960 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY, 0);
Srikanth Chintala079912a2016-03-03 16:35:01 +0530961 phoneInEcm = PhoneFactory.getPhone(phoneId);
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530962 Log.d(LOG_TAG, "Emergency Callback Mode. phoneId:" + phoneId);
963 if (phoneInEcm != null) {
964 if (TelephonyCapabilities.supportsEcm(phoneInEcm)) {
965 Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp.");
966 // Start Emergency Callback Mode service
Daniel Bright30efde42020-01-09 22:11:15 -0800967 if (intent.getBooleanExtra(
968 TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, false)) {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530969 context.startService(new Intent(context,
970 EmergencyCallbackModeService.class));
971 } else {
972 phoneInEcm = null;
973 }
974 } else {
975 // It doesn't make sense to get ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
976 // on a device that doesn't support ECM in the first place.
977 Log.e(LOG_TAG, "Got ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, but "
978 + "ECM isn't supported for phone: " + phoneInEcm.getPhoneName());
979 phoneInEcm = null;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700980 }
981 } else {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530982 Log.w(LOG_TAG, "phoneInEcm is null.");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700983 }
Jack Yu1a2fc352017-07-14 17:14:37 -0700984 } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) {
985 // Roaming status could be overridden by carrier config, so we need to update it.
986 if (VDBG) Log.v(LOG_TAG, "carrier config changed.");
sangyun1c1918a2023-11-13 22:37:50 +0900987 if (mFeatureFlags.reorganizeRoamingNotification()) {
988 updateDataRoamingStatus(ROAMING_NOTIFICATION_REASON_CARRIER_CONFIG_CHANGED);
989 } else {
990 updateDataRoamingStatusForFeatureDisabled(null);
991 }
chen xubaf9fe52019-07-02 17:28:24 -0700992 updateLimitedSimFunctionForDualSim();
Lei Liu863eac02020-06-24 20:12:55 +0800993 int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
994 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
995 if (SubscriptionManager.isValidSubscriptionId(subId)) {
996 mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARRIER_CONFIG_CHANGED,
997 new Integer(subId)));
998 }
Jack Yu1a2fc352017-07-14 17:14:37 -0700999 } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
1000 // We also need to pay attention when default data subscription changes.
1001 if (VDBG) Log.v(LOG_TAG, "default data sub changed.");
1002 mDefaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
1003 registerSettingsObserver();
1004 Phone phone = getPhone(mDefaultDataSubId);
1005 if (phone != null) {
sangyun1c1918a2023-11-13 22:37:50 +09001006 if (mFeatureFlags.reorganizeRoamingNotification()) {
1007 updateDataRoamingStatus(
1008 ROAMING_NOTIFICATION_REASON_DEFAULT_DATA_SUBS_CHANGED);
1009 } else {
1010 updateDataRoamingStatusForFeatureDisabled(null);
1011 }
Jack Yu1a2fc352017-07-14 17:14:37 -07001012 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001013 }
1014 }
1015 }
1016
Sarah Chin072ffb22022-05-03 17:58:59 -07001017 private void handleServiceStateChanged(ServiceState serviceState, int subId) {
Jack Yu1a2fc352017-07-14 17:14:37 -07001018 if (VDBG) Log.v(LOG_TAG, "handleServiceStateChanged");
Sarah Chin072ffb22022-05-03 17:58:59 -07001019 int state = serviceState.getState();
1020 notificationMgr.updateNetworkSelection(state, subId);
Jack Yu1a2fc352017-07-14 17:14:37 -07001021
Sarah Chin072ffb22022-05-03 17:58:59 -07001022 if (VDBG) {
1023 Log.v(LOG_TAG, "subId=" + subId + ", mDefaultDataSubId="
1024 + mDefaultDataSubId + ", ss roaming=" + serviceState.getDataRoaming());
1025 }
1026 if (subId == mDefaultDataSubId) {
sangyun1c1918a2023-11-13 22:37:50 +09001027 if (mFeatureFlags.reorganizeRoamingNotification()) {
1028 updateDataRoamingStatus(ROAMING_NOTIFICATION_REASON_SERVICE_STATE_CHANGED);
1029 } else {
1030 updateDataRoamingStatusForFeatureDisabled(serviceState.getOperatorNumeric());
1031 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001032 }
1033 }
1034
Jack Yu1a2fc352017-07-14 17:14:37 -07001035 /**
1036 * When roaming, if mobile data cannot be established due to data roaming not enabled, we need
1037 * to notify the user so they can enable it through settings. Vise versa if the condition
1038 * changes, we need to dismiss the notification.
sangyund2cfeaa2024-03-31 12:20:40 +09001039 * @param notificationReason to inform which event is called for notification update.
Jack Yu1a2fc352017-07-14 17:14:37 -07001040 */
sangyund2cfeaa2024-03-31 12:20:40 +09001041 private void updateDataRoamingStatus(@RoamingNotificationReason int notificationReason) {
Jack Yu1a2fc352017-07-14 17:14:37 -07001042 Phone phone = getPhone(mDefaultDataSubId);
1043 if (phone == null) {
1044 Log.w(LOG_TAG, "Can't get phone with sub id = " + mDefaultDataSubId);
1045 return;
1046 }
1047
sangyun35f23f82023-07-18 01:37:53 +09001048 ServiceState serviceState = phone.getServiceState();
Thomas Nguyen4f9c89e2023-12-18 10:51:57 -08001049 if (serviceState == null) {
1050 Log.e(LOG_TAG, "updateDataRoamingStatus: serviceState is null");
1051 return;
1052 }
1053
sangyund2cfeaa2024-03-31 12:20:40 +09001054 List<DataDisallowedReason> disallowReasons = phone.getDataNetworkController()
1055 .getInternetDataDisallowedReasons();
1056
1057 if (mFeatureFlags.roamingNotificationForSingleDataNetwork()) {
1058 if (disallowReasons.contains(DataDisallowedReason.ONLY_ALLOWED_SINGLE_NETWORK)
1059 && disallowReasons.contains(DataDisallowedReason.ROAMING_DISABLED)
1060 && (notificationReason == ROAMING_NOTIFICATION_REASON_DATA_SETTING_CHANGED
1061 || notificationReason
1062 == ROAMING_NOTIFICATION_REASON_DATA_ROAMING_SETTING_CHANGED)) {
1063 // If the ONLY_ALLOWED_SINGLE_NETWORK disallow reason has not yet been removed due
1064 // to a change in mobile_data (including roaming_data) settings, update roaming
1065 // notification again after the Internet is completely disconnected to check
1066 // ONLY_ALLOWED_SINGLE_NETWORK disallow reason is removed.
1067 mWaitForInternetDisconnection.set(true);
1068 Log.d(LOG_TAG, "updateDataRoamingStatus,"
1069 + " wait for internet disconnection for single data network");
1070 } else if (!disallowReasons.contains(DataDisallowedReason.ONLY_ALLOWED_SINGLE_NETWORK)
1071 && mWaitForInternetDisconnection.compareAndSet(true, false)) {
1072 // If the ONLY_ALLOWED_SINGLE_NETWORK disallow reason has been removed,
1073 // no longer wait for Internet disconnection.
1074 Log.d(LOG_TAG, "updateDataRoamingStatus,"
1075 + " cancel to wait for internet disconnection for single data network");
1076 }
1077 }
1078
1079 updateDataRoamingStatus(notificationReason, disallowReasons, serviceState);
1080 }
1081
1082 /**
1083 * When roaming, if mobile data cannot be established due to data roaming not enabled, we need
1084 * to notify the user so they can enable it through settings. Vise versa if the condition
1085 * changes, we need to dismiss the notification.
1086 * @param notificationReason to inform which event is called for notification update.
1087 * @param disallowReasons List of reasons why internet data is not allowed. An empty list if
1088 * internet is allowed.
1089 * @param serviceState Service state from phone
1090 */
1091 private void updateDataRoamingStatus(@RoamingNotificationReason int notificationReason,
1092 List<DataDisallowedReason> disallowReasons, ServiceState serviceState) {
1093
1094 if (VDBG) Log.v(LOG_TAG, "updateDataRoamingStatus");
sangyun35f23f82023-07-18 01:37:53 +09001095 String roamingNumeric = serviceState.getOperatorNumeric();
1096 String roamingNumericReason = "RoamingNumeric=" + roamingNumeric;
sangyund2cfeaa2024-03-31 12:20:40 +09001097 String callingReason = "CallingReason=" + notificationReason;
sangyun35f23f82023-07-18 01:37:53 +09001098 boolean dataIsNowRoaming = serviceState.getDataRoaming();
Jack Yu3e2ac6e2022-03-26 13:59:45 -07001099 boolean dataAllowed;
1100 boolean notAllowedDueToRoamingOff;
sangyund2cfeaa2024-03-31 12:20:40 +09001101 dataAllowed = disallowReasons.isEmpty();
1102 notAllowedDueToRoamingOff = (disallowReasons.size() == 1
1103 && disallowReasons.contains(DataDisallowedReason.ROAMING_DISABLED));
sangyun35f23f82023-07-18 01:37:53 +09001104 StringBuilder sb = new StringBuilder("updateDataRoamingStatus");
1105 sb.append(" dataAllowed=").append(dataAllowed);
sangyund2cfeaa2024-03-31 12:20:40 +09001106 sb.append(", disallowReasons=").append(disallowReasons);
sangyun35f23f82023-07-18 01:37:53 +09001107 sb.append(", dataIsNowRoaming=").append(dataIsNowRoaming);
1108 sb.append(", ").append(roamingNumericReason);
1109 sb.append(", ").append(callingReason);
1110 mDataRoamingNotifLog.log(sb.toString());
Ling Ma317906d2022-12-05 15:58:14 -08001111 if (VDBG) {
sangyun35f23f82023-07-18 01:37:53 +09001112 Log.v(LOG_TAG, sb.toString());
Ling Ma317906d2022-12-05 15:58:14 -08001113 }
Jack Yu3e2ac6e2022-03-26 13:59:45 -07001114
sangyun35f23f82023-07-18 01:37:53 +09001115 // Determine if a given roaming numeric has never been shown.
1116 boolean shownInThisNumeric = false;
sangyund2cfeaa2024-03-31 12:20:40 +09001117 if (notificationReason == ROAMING_NOTIFICATION_REASON_CARRIER_CONFIG_CHANGED
1118 || notificationReason == ROAMING_NOTIFICATION_REASON_SERVICE_STATE_CHANGED) {
sangyun35f23f82023-07-18 01:37:53 +09001119 shownInThisNumeric = mShownNotificationReasons.contains(roamingNumericReason);
1120 }
1121 // Determine if a notification has never been shown by given calling reason.
1122 boolean shownForThisReason = mShownNotificationReasons.contains(callingReason);
1123
Jack Yu3e2ac6e2022-03-26 13:59:45 -07001124 if (!dataAllowed && notAllowedDueToRoamingOff) {
sangyun35f23f82023-07-18 01:37:53 +09001125 if (!shownInThisNumeric && roamingNumeric != null) {
1126 mShownNotificationReasons.add(roamingNumericReason);
1127 }
1128 if (!shownForThisReason
sangyund2cfeaa2024-03-31 12:20:40 +09001129 && notificationReason == ROAMING_NOTIFICATION_REASON_CARRIER_CONFIG_CHANGED) {
sangyun35f23f82023-07-18 01:37:53 +09001130 mShownNotificationReasons.add(callingReason);
Ling Ma4e15c322022-12-07 11:20:53 -08001131 }
Jordan Liuff2ccd72019-07-23 15:54:41 -07001132 // No need to show it again if we never cancelled it explicitly.
sangyun35f23f82023-07-18 01:37:53 +09001133 if (getCurrentRoamingNotification() == ROAMING_NOTIFICATION_DISCONNECTED) {
1134 return;
1135 }
1136
Jack Yu1a2fc352017-07-14 17:14:37 -07001137 // If the only reason of no data is data roaming disabled, then we notify the user
1138 // so the user can turn on data roaming.
sangyun35f23f82023-07-18 01:37:53 +09001139 if (!shownInThisNumeric && !shownForThisReason) {
1140 updateDataRoamingNotification(ROAMING_NOTIFICATION_DISCONNECTED);
1141 } else {
1142 // Don't show roaming notification if we've already shown for this MccMnc
1143 Log.d(LOG_TAG, "Skip roaming disconnected notification since already"
1144 + " shownInThisNumeric=" + shownInThisNumeric
1145 + " shownForThisReason=" + shownForThisReason);
1146 // Dismiss notification if the other notification is shown.
1147 if (getCurrentRoamingNotification() != ROAMING_NOTIFICATION_NO_NOTIFICATION) {
1148 updateDataRoamingNotification(ROAMING_NOTIFICATION_NO_NOTIFICATION);
1149 }
1150 }
1151 } else if (dataAllowed && dataIsNowRoaming) {
1152 if (!shownInThisNumeric && roamingNumeric != null) {
1153 mShownNotificationReasons.add(roamingNumericReason);
1154 }
1155 if (!shownForThisReason
sangyund2cfeaa2024-03-31 12:20:40 +09001156 && notificationReason == ROAMING_NOTIFICATION_REASON_CARRIER_CONFIG_CHANGED) {
sangyun35f23f82023-07-18 01:37:53 +09001157 mShownNotificationReasons.add(callingReason);
1158 }
Sarah Chin37b39072023-11-05 13:28:21 -08001159 boolean shouldShowRoamingNotification = shouldShowRoamingNotification(roamingNumeric);
sangyun35f23f82023-07-18 01:37:53 +09001160 // No need to show it again if we never cancelled it explicitly.
1161 if (getCurrentRoamingNotification() == ROAMING_NOTIFICATION_CONNECTED) {
Ling Ma4e15c322022-12-07 11:20:53 -08001162 return;
1163 }
sangyun35f23f82023-07-18 01:37:53 +09001164
1165 // Inform users that roaming charges may apply.
Sarah Chin37b39072023-11-05 13:28:21 -08001166 if (!shownInThisNumeric && !shownForThisReason && shouldShowRoamingNotification) {
sangyun35f23f82023-07-18 01:37:53 +09001167 updateDataRoamingNotification(ROAMING_NOTIFICATION_CONNECTED);
1168 } else {
1169 // Don't show roaming notification if we've already shown for this MccMnc or
1170 // disabled from carrier config.
1171 Log.d(LOG_TAG, "Skip roaming connected notification since already"
1172 + " shownInThisNumeric:" + shownInThisNumeric
1173 + " shownForThisReason:" + shownForThisReason
Sarah Chin37b39072023-11-05 13:28:21 -08001174 + " shouldShowRoamingNotification:" + shouldShowRoamingNotification);
sangyun35f23f82023-07-18 01:37:53 +09001175 // Dismiss notification if the other notification is shown.
1176 if (getCurrentRoamingNotification() != ROAMING_NOTIFICATION_NO_NOTIFICATION) {
1177 updateDataRoamingNotification(ROAMING_NOTIFICATION_NO_NOTIFICATION);
1178 }
1179 }
1180 } else if (getCurrentRoamingNotification() != ROAMING_NOTIFICATION_NO_NOTIFICATION) {
Jordan Liuff2ccd72019-07-23 15:54:41 -07001181 // Otherwise we either 1) we are not roaming or 2) roaming is off but ROAMING_DISABLED
1182 // is not the only data disable reason. In this case we dismiss the notification we
1183 // showed earlier.
sangyun35f23f82023-07-18 01:37:53 +09001184 updateDataRoamingNotification(ROAMING_NOTIFICATION_NO_NOTIFICATION);
Jack Yu1a2fc352017-07-14 17:14:37 -07001185 }
1186 }
1187
sangyun35f23f82023-07-18 01:37:53 +09001188 private void updateDataRoamingNotification(@RoamingNotification int roamingNotification) {
1189 int event;
1190 switch (roamingNotification) {
1191 case ROAMING_NOTIFICATION_NO_NOTIFICATION:
1192 Log.d(LOG_TAG, "Dismiss roaming notification");
1193 mDataRoamingNotifLog.log("Hide roaming.");
1194 event = EVENT_DATA_ROAMING_OK;
1195 break;
1196 case ROAMING_NOTIFICATION_CONNECTED:
1197 Log.d(LOG_TAG, "Show roaming connected notification");
1198 mDataRoamingNotifLog.log("Show roaming on.");
1199 event = EVENT_DATA_ROAMING_CONNECTED;
1200 break;
1201 case ROAMING_NOTIFICATION_DISCONNECTED:
1202 Log.d(LOG_TAG, "Show roaming disconnected notification");
1203 mDataRoamingNotifLog.log("Show roaming off.");
1204 event = EVENT_DATA_ROAMING_DISCONNECTED;
1205 break;
1206 default:
1207 Log.d(LOG_TAG, "Should never reach here.");
1208 mDataRoamingNotifLog.log("Should never reach here.");
1209 return;
1210 }
1211 mCurrentRoamingNotification = roamingNotification;
1212 mHandler.obtainMessage(event, mDefaultDataSubId, 0).sendToTarget();
1213 }
1214
1215 private @RoamingNotification int getCurrentRoamingNotification() {
1216 return mCurrentRoamingNotification;
1217 }
1218
sangyun1c1918a2023-11-13 22:37:50 +09001219 // For reorganize_roaming_notification feature disabled.
1220 /**
1221 * When roaming, if mobile data cannot be established due to data roaming not enabled, we need
1222 * to notify the user so they can enable it through settings. Vise versa if the condition
1223 * changes, we need to dismiss the notification.
1224 * @param roamingOperatorNumeric The operator numeric for the current roaming. {@code null} if
1225 * the current roaming operator numeric didn't change.
1226 */
1227 private void updateDataRoamingStatusForFeatureDisabled(
1228 @Nullable String roamingOperatorNumeric) {
1229 if (VDBG) Log.v(LOG_TAG, "updateDataRoamingStatusForFeatureDisabled");
1230 Phone phone = getPhone(mDefaultDataSubId);
1231 if (phone == null) {
1232 Log.w(LOG_TAG, "Can't get phone with sub id = " + mDefaultDataSubId);
1233 return;
1234 }
1235
1236 boolean dataAllowed;
1237 boolean notAllowedDueToRoamingOff;
1238 List<DataDisallowedReason> reasons = phone.getDataNetworkController()
1239 .getInternetDataDisallowedReasons();
1240 dataAllowed = reasons.isEmpty();
1241 notAllowedDueToRoamingOff = (reasons.size() == 1
1242 && reasons.contains(DataDisallowedReason.ROAMING_DISABLED));
1243 mDataRoamingNotifLog.log("dataAllowed=" + dataAllowed + ", reasons=" + reasons
1244 + ", roamingOperatorNumeric=" + roamingOperatorNumeric);
1245 if (VDBG) {
1246 Log.v(LOG_TAG, "dataAllowed=" + dataAllowed + ", reasons=" + reasons
1247 + ", roamingOperatorNumeric=" + roamingOperatorNumeric);
1248 }
1249
1250 if (!dataAllowed && notAllowedDueToRoamingOff) {
1251 // Don't show roaming notification if we've already shown for this MccMnc
1252 if (roamingOperatorNumeric != null
1253 && !mPrevRoamingOperatorNumerics.add(roamingOperatorNumeric)) {
1254 Log.d(LOG_TAG, "Skip roaming disconnected notification since already shown in "
1255 + "MccMnc " + roamingOperatorNumeric);
1256 return;
1257 }
1258 // No need to show it again if we never cancelled it explicitly.
1259 if (mPrevRoamingNotification == ROAMING_NOTIFICATION_DISCONNECTED) return;
1260 // If the only reason of no data is data roaming disabled, then we notify the user
1261 // so the user can turn on data roaming.
1262 mPrevRoamingNotification = ROAMING_NOTIFICATION_DISCONNECTED;
1263 Log.d(LOG_TAG, "Show roaming disconnected notification");
1264 mDataRoamingNotifLog.log("Show roaming off.");
1265 Message msg = mHandler.obtainMessage(EVENT_DATA_ROAMING_DISCONNECTED);
1266 msg.arg1 = mDefaultDataSubId;
1267 msg.sendToTarget();
1268 } else if (dataAllowed && dataIsNowRoaming(mDefaultDataSubId)) {
sangyun5abbf7e2024-02-01 00:47:30 +09001269 if (!shouldShowRoamingNotification(roamingOperatorNumeric != null
1270 ? roamingOperatorNumeric : phone.getServiceState().getOperatorNumeric())) {
Sarah Chin37b39072023-11-05 13:28:21 -08001271 Log.d(LOG_TAG, "Skip showing roaming connected notification.");
1272 return;
1273 }
sangyun1c1918a2023-11-13 22:37:50 +09001274 // Don't show roaming notification if we've already shown for this MccMnc
1275 if (roamingOperatorNumeric != null
1276 && !mPrevRoamingOperatorNumerics.add(roamingOperatorNumeric)) {
1277 Log.d(LOG_TAG, "Skip roaming connected notification since already shown in "
1278 + "MccMnc " + roamingOperatorNumeric);
1279 return;
1280 }
1281 // No need to show it again if we never cancelled it explicitly, or carrier config
1282 // indicates this is not needed.
1283 if (mPrevRoamingNotification == ROAMING_NOTIFICATION_CONNECTED) return;
1284 mPrevRoamingNotification = ROAMING_NOTIFICATION_CONNECTED;
1285 Log.d(LOG_TAG, "Show roaming connected notification");
1286 mDataRoamingNotifLog.log("Show roaming on.");
1287 Message msg = mHandler.obtainMessage(EVENT_DATA_ROAMING_CONNECTED);
1288 msg.arg1 = mDefaultDataSubId;
1289 msg.sendToTarget();
1290 } else if (mPrevRoamingNotification != ROAMING_NOTIFICATION_NO_NOTIFICATION) {
1291 // Otherwise we either 1) we are not roaming or 2) roaming is off but ROAMING_DISABLED
1292 // is not the only data disable reason. In this case we dismiss the notification we
1293 // showed earlier.
1294 mPrevRoamingNotification = ROAMING_NOTIFICATION_NO_NOTIFICATION;
1295 Log.d(LOG_TAG, "Dismiss roaming notification");
1296 mDataRoamingNotifLog.log("Hide. data allowed=" + dataAllowed);
1297 mHandler.sendEmptyMessage(EVENT_DATA_ROAMING_OK);
1298 }
1299 }
1300
Jordan Liuff2ccd72019-07-23 15:54:41 -07001301 /**
1302 *
1303 * @param subId to check roaming on
1304 * @return whether we have transitioned to dataRoaming
1305 */
1306 private boolean dataIsNowRoaming(int subId) {
Sarah Chine04784a2022-10-31 20:32:34 -07001307 return getPhone(subId).getServiceState().getDataRoaming();
Jordan Liuff2ccd72019-07-23 15:54:41 -07001308 }
1309
Sarah Chin37b39072023-11-05 13:28:21 -08001310 private boolean shouldShowRoamingNotification(String roamingNumeric) {
1311 PersistableBundle config = getCarrierConfigForSubId(mDefaultDataSubId);
1312 boolean showRoamingNotification = config.getBoolean(
1313 CarrierConfigManager.KEY_SHOW_DATA_CONNECTED_ROAMING_NOTIFICATION_BOOL);
1314
1315 if (TextUtils.isEmpty(roamingNumeric) || !mFeatureFlags.hideRoamingIcon()) {
1316 Log.d(LOG_TAG, "shouldShowRoamingNotification: roamingNumeric=" + roamingNumeric
1317 + ", hideRoaming=" + mFeatureFlags.hideRoamingIcon());
1318 return showRoamingNotification;
1319 }
1320
1321 String[] includedMccMncs = config.getStringArray(CarrierConfigManager
1322 .KEY_DATA_CONNECTED_ROAMING_NOTIFICATION_INCLUDED_MCC_MNCS_STRING_ARRAY);
1323 if (includedMccMncs != null) {
1324 for (String mccMnc : includedMccMncs) {
1325 if (roamingNumeric.equals(mccMnc)) {
1326 Log.d(LOG_TAG, "shouldShowRoamingNotification: show for MCC/MNC " + mccMnc);
1327 return showRoamingNotification;
1328 }
1329 }
1330 }
1331
1332 String[] excludedMccs = config.getStringArray(CarrierConfigManager
1333 .KEY_DATA_CONNECTED_ROAMING_NOTIFICATION_EXCLUDED_MCCS_STRING_ARRAY);
1334 String roamingMcc = roamingNumeric.length() < 3 ? "" : roamingNumeric.substring(0, 3);
1335 if (excludedMccs != null && !TextUtils.isEmpty(roamingMcc)) {
1336 for (String mcc : excludedMccs) {
1337 if (roamingMcc.equals(mcc)) {
1338 Log.d(LOG_TAG, "shouldShowRoamingNotification: ignore for MCC " + mcc);
1339 return false;
1340 }
1341 }
1342 }
1343
1344 if (showRoamingNotification) {
1345 Log.d(LOG_TAG, "shouldShowRoamingNotification: show for numeric " + roamingNumeric);
1346 }
1347 return showRoamingNotification;
1348 }
1349
chen xubaf9fe52019-07-02 17:28:24 -07001350 private void updateLimitedSimFunctionForDualSim() {
1351 if (DBG) Log.d(LOG_TAG, "updateLimitedSimFunctionForDualSim");
1352 // check conditions to display limited SIM function notification under dual SIM
1353 SubscriptionManager subMgr = (SubscriptionManager) getSystemService(
1354 Context.TELEPHONY_SUBSCRIPTION_SERVICE);
1355 List<SubscriptionInfo> subList = subMgr.getActiveSubscriptionInfoList(false);
1356 if (subList != null && subList.size() > 1) {
1357 CarrierConfigManager configMgr = (CarrierConfigManager)
1358 getSystemService(Context.CARRIER_CONFIG_SERVICE);
1359 for (SubscriptionInfo info : subList) {
1360 PersistableBundle b = configMgr.getConfigForSubId(info.getSubscriptionId());
1361 if (b != null) {
1362 if (b.getBoolean(CarrierConfigManager
1363 .KEY_LIMITED_SIM_FUNCTION_NOTIFICATION_FOR_DSDS_BOOL)) {
1364 notificationMgr.showLimitedSimFunctionWarningNotification(
1365 info.getSubscriptionId(),
1366 info.getDisplayName().toString());
1367 } else {
1368 notificationMgr.dismissLimitedSimFunctionWarningNotification(
1369 info.getSubscriptionId());
1370 }
1371 }
1372 }
1373 } else {
1374 // cancel notifications for all subs
1375 notificationMgr.dismissLimitedSimFunctionWarningNotification(
1376 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
1377 }
1378 notificationMgr.dismissLimitedSimFunctionWarningNotificationForInactiveSubs();
1379
1380 }
1381
Sandeep Kuntade73a6a2014-10-15 18:45:56 +05301382 public Phone getPhoneInEcm() {
1383 return phoneInEcm;
1384 }
1385
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001386 /**
Tyler Gunn9c1071f2014-12-09 10:07:54 -08001387 * Triggers a refresh of the message waiting (voicemail) indicator.
1388 *
1389 * @param subId the subscription id we should refresh the notification for.
1390 */
1391 public void refreshMwiIndicator(int subId) {
1392 notificationMgr.refreshMwi(subId);
1393 }
1394
1395 /**
Pengquan Mengdd9ac822018-09-20 15:25:35 -07001396 * Called when the network selection on the subscription {@code subId} is changed by the user.
1397 *
1398 * @param subId the subscription id.
1399 */
1400 public void onNetworkSelectionChanged(int subId) {
1401 Phone phone = getPhone(subId);
1402 if (phone != null) {
1403 notificationMgr.updateNetworkSelection(phone.getServiceState().getState(), subId);
1404 } else {
1405 Log.w(LOG_TAG, "onNetworkSelectionChanged on null phone, subId: " + subId);
1406 }
1407 }
1408
1409 /**
James.cf Lin4b784aa2021-01-31 03:25:15 +08001410 * @return whether the device supports RCS User Capability Exchange or not.
1411 */
1412 public boolean getDeviceUceEnabled() {
1413 return (mTelephonyRcsService == null) ? false : mTelephonyRcsService.isDeviceUceEnabled();
1414 }
1415
1416 /**
1417 * Set the device supports RCS User Capability Exchange.
1418 * @param isEnabled true if the device supports UCE.
1419 */
1420 public void setDeviceUceEnabled(boolean isEnabled) {
1421 if (mTelephonyRcsService != null) {
1422 mTelephonyRcsService.setDeviceUceEnabled(isEnabled);
1423 }
1424 }
1425
1426 /**
Jack Yu1a2fc352017-07-14 17:14:37 -07001427 * Dump the state of the object, add calls to other objects as desired.
1428 *
1429 * @param fd File descriptor
1430 * @param printWriter Print writer
1431 * @param args Arguments
1432 */
1433 public void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) {
1434 IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " ");
1435 pw.println("------- PhoneGlobals -------");
1436 pw.increaseIndent();
sangyun15019e02023-11-13 21:50:15 +09001437 pw.println("FeatureFlags:");
1438 pw.increaseIndent();
sangyun1c1918a2023-11-13 22:37:50 +09001439 pw.println("reorganizeRoamingNotification="
1440 + mFeatureFlags.reorganizeRoamingNotification());
sangyund5f37ab2023-11-13 22:52:28 +09001441 pw.println("dismissNetworkSelectionNotificationOnSimDisable="
1442 + mFeatureFlags.dismissNetworkSelectionNotificationOnSimDisable());
sangyun15019e02023-11-13 21:50:15 +09001443 pw.decreaseIndent();
sangyun1c1918a2023-11-13 22:37:50 +09001444 if (mFeatureFlags.reorganizeRoamingNotification()) {
1445 pw.println("mCurrentRoamingNotification=" + mCurrentRoamingNotification);
1446 } else {
1447 pw.println("mPrevRoamingNotification=" + mPrevRoamingNotification);
1448 }
Jack Yu1a2fc352017-07-14 17:14:37 -07001449 pw.println("mDefaultDataSubId=" + mDefaultDataSubId);
Keun young Parkdebb8532019-05-30 16:35:27 -07001450 pw.println("isSmsCapable=" + TelephonyManager.from(this).isSmsCapable());
sangyun35f23f82023-07-18 01:37:53 +09001451 pw.println("mDataRoamingNotifLog:");
Jack Yu1a2fc352017-07-14 17:14:37 -07001452 pw.increaseIndent();
1453 mDataRoamingNotifLog.dump(fd, pw, args);
1454 pw.decreaseIndent();
Brad Ebinger05f52c22019-12-05 13:03:21 -08001455 pw.println("ImsResolver:");
1456 pw.increaseIndent();
1457 try {
Brad Ebingerd1947d82021-05-17 20:54:49 +00001458 if (ImsResolver.getInstance() != null) ImsResolver.getInstance().dump(fd, pw, args);
Brad Ebinger05f52c22019-12-05 13:03:21 -08001459 } catch (Exception e) {
1460 e.printStackTrace();
1461 }
1462 pw.decreaseIndent();
Brad Ebingera68a4972020-01-30 17:31:23 -08001463 pw.println("RcsService:");
1464 try {
1465 if (mTelephonyRcsService != null) mTelephonyRcsService.dump(fd, pw, args);
1466 } catch (Exception e) {
1467 e.printStackTrace();
1468 }
Hunsuk Choi89bd22c2021-11-01 13:04:54 +00001469 pw.println("ImsStateCallbackController:");
1470 try {
1471 if (mImsStateCallbackController != null) mImsStateCallbackController.dump(pw);
1472 } catch (Exception e) {
1473 e.printStackTrace();
1474 }
Hwangoo Parkba21cf22022-11-30 14:34:04 +00001475 pw.println("DomainSelectionResolver:");
1476 pw.increaseIndent();
1477 try {
1478 if (DomainSelectionResolver.getInstance() != null) {
1479 DomainSelectionResolver.getInstance().dump(fd, pw, args);
1480 }
1481 } catch (Exception e) {
1482 e.printStackTrace();
1483 }
1484 pw.decreaseIndent();
Jack Yu1a2fc352017-07-14 17:14:37 -07001485 pw.decreaseIndent();
sangyun1c1918a2023-11-13 22:37:50 +09001486 if (mFeatureFlags.reorganizeRoamingNotification()) {
1487 pw.println("mShownNotificationReasons=" + mShownNotificationReasons);
1488 } else {
1489 pw.println("mPrevRoamingOperatorNumerics:" + mPrevRoamingOperatorNumerics);
1490 }
Jack Yu1a2fc352017-07-14 17:14:37 -07001491 pw.println("------- End PhoneGlobals -------");
1492 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001493}