blob: 3d82e74806da847c5129422d8565c9c4199131d9 [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
19import android.app.Activity;
20import android.app.KeyguardManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070021import android.app.ProgressDialog;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070022import android.content.BroadcastReceiver;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070023import android.content.ContentResolver;
24import android.content.Context;
25import android.content.ContextWrapper;
26import android.content.Intent;
27import android.content.IntentFilter;
Youming Ye47a6adc2018-11-19 15:33:36 -080028import android.content.res.XmlResourceParser;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070029import android.media.AudioManager;
Santos Cordone18902f2016-03-22 17:16:04 -070030import android.net.ConnectivityManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070031import android.net.Uri;
Brad Ebinger533c6c12017-08-02 11:38:48 -070032import android.net.sip.SipManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070033import android.os.AsyncResult;
Junda Liu605148f2015-04-28 15:23:40 -070034import android.os.Bundle;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070035import android.os.Handler;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070036import android.os.Message;
Jonathan Basseric31f1f32015-05-12 10:13:03 -070037import android.os.PersistableBundle;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070038import android.os.PowerManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070039import android.os.SystemClock;
40import android.os.SystemProperties;
41import android.os.UpdateLock;
Brad Ebinger3fa43462016-04-12 16:06:48 -070042import android.os.UserManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070043import android.preference.PreferenceManager;
Sanket Padawe4c699232016-02-09 11:07:22 -080044import android.provider.Settings;
Tyler Gunn900d8fd2018-09-21 09:22:12 -070045import android.telecom.TelecomManager;
Junda Liu12f7d802015-05-01 12:06:44 -070046import android.telephony.CarrierConfigManager;
Nathan Harold0db5c5e2019-01-22 20:18:56 -080047import android.telephony.DebugEventReporter;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070048import android.telephony.ServiceState;
Andrew Lee385019f2014-11-24 14:19:50 -080049import android.telephony.SubscriptionManager;
Jack Yu1a2fc352017-07-14 17:14:37 -070050import android.telephony.TelephonyManager;
Jack Yu311536f2018-11-26 11:20:48 -080051import android.telephony.data.ApnSetting;
Jack Yu1a2fc352017-07-14 17:14:37 -070052import android.util.LocalLog;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070053import android.util.Log;
Santos Cordone18902f2016-03-22 17:16:04 -070054import android.widget.Toast;
Ta-wei Yenb29425b2016-09-21 17:28:14 -070055
Santos Cordon7d4ddf62013-07-10 11:58:08 -070056import com.android.internal.telephony.CallManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070057import com.android.internal.telephony.IccCardConstants;
58import com.android.internal.telephony.MmiCode;
59import com.android.internal.telephony.Phone;
60import com.android.internal.telephony.PhoneConstants;
61import com.android.internal.telephony.PhoneFactory;
Jack Yu1a2fc352017-07-14 17:14:37 -070062import com.android.internal.telephony.SettingsObserver;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070063import com.android.internal.telephony.TelephonyCapabilities;
Youming Ye47a6adc2018-11-19 15:33:36 -080064import com.android.internal.telephony.TelephonyComponentFactory;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070065import com.android.internal.telephony.TelephonyIntents;
Jack Yu1a2fc352017-07-14 17:14:37 -070066import com.android.internal.telephony.dataconnection.DataConnectionReasons;
67import com.android.internal.telephony.dataconnection.DataConnectionReasons.DataDisallowedReasonType;
68import com.android.internal.util.IndentingPrintWriter;
Andrew Leefb7f92e2015-02-26 16:23:32 -080069import com.android.phone.settings.SettingsConstants;
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -070070import com.android.phone.vvm.CarrierVvmPackageInstalledReceiver;
Brad Ebinger28626122017-08-10 14:13:35 -070071import com.android.services.telephony.sip.SipAccountRegistry;
Brad Ebinger3fa43462016-04-12 16:06:48 -070072import com.android.services.telephony.sip.SipUtil;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070073
Jack Yu1a2fc352017-07-14 17:14:37 -070074import java.io.FileDescriptor;
75import java.io.PrintWriter;
76
Santos Cordon7d4ddf62013-07-10 11:58:08 -070077/**
78 * Global state for the telephony subsystem when running in the primary
79 * phone process.
80 */
Sailesh Nepalbf900542014-07-15 16:18:32 -070081public class PhoneGlobals extends ContextWrapper {
Jack Yu1a2fc352017-07-14 17:14:37 -070082 public static final String LOG_TAG = "PhoneGlobals";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070083
84 /**
85 * Phone app-wide debug level:
86 * 0 - no debug logging
87 * 1 - normal debug logging if ro.debuggable is set (which is true in
88 * "eng" and "userdebug" builds but not "user" builds)
89 * 2 - ultra-verbose debug logging
90 *
91 * Most individual classes in the phone app have a local DBG constant,
92 * typically set to
93 * (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1)
94 * or else
95 * (PhoneApp.DBG_LEVEL >= 2)
96 * depending on the desired verbosity.
97 *
98 * ***** DO NOT SUBMIT WITH DBG_LEVEL > 0 *************
99 */
Andrew Lee88b51e22014-10-29 15:48:51 -0700100 public static final int DBG_LEVEL = 0;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700101
102 private static final boolean DBG =
103 (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
104 private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
105
106 // Message codes; see mHandler below.
107 private static final int EVENT_SIM_NETWORK_LOCKED = 3;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700108 private static final int EVENT_SIM_STATE_CHANGED = 8;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700109 private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10;
110 private static final int EVENT_DATA_ROAMING_OK = 11;
111 private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 12;
Brad Ebinger3fa43462016-04-12 16:06:48 -0700112 private static final int EVENT_RESTART_SIP = 13;
Jack Yu1a2fc352017-07-14 17:14:37 -0700113 private static final int EVENT_DATA_ROAMING_SETTINGS_CHANGED = 14;
114 private static final int EVENT_MOBILE_DATA_SETTINGS_CHANGED = 15;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700115
116 // The MMI codes are also used by the InCallScreen.
117 public static final int MMI_INITIATE = 51;
118 public static final int MMI_COMPLETE = 52;
119 public static final int MMI_CANCEL = 53;
120 // Don't use message codes larger than 99 here; those are reserved for
121 // the individual Activities of the Phone UI.
122
Santos Cordone18902f2016-03-22 17:16:04 -0700123 public static final int AIRPLANE_ON = 1;
124 public static final int AIRPLANE_OFF = 0;
125
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700126 /**
127 * Allowable values for the wake lock code.
128 * SLEEP means the device can be put to sleep.
129 * PARTIAL means wake the processor, but we display can be kept off.
130 * FULL means wake both the processor and the display.
131 */
132 public enum WakeState {
133 SLEEP,
134 PARTIAL,
135 FULL
136 }
137
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700138 private static PhoneGlobals sMe;
139
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700140 CallManager mCM;
Santos Cordon63a84242013-07-23 13:32:52 -0700141 CallNotifier notifier;
142 CallerInfoCache callerInfoCache;
Santos Cordon63a84242013-07-23 13:32:52 -0700143 NotificationMgr notificationMgr;
Andrew Lee9431b832015-03-09 18:46:45 -0700144 public PhoneInterfaceManager phoneMgr;
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800145 CarrierConfigLoader configLoader;
Santos Cordon63a84242013-07-23 13:32:52 -0700146
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530147 private Phone phoneInEcm;
Santos Cordon63a84242013-07-23 13:32:52 -0700148
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700149 static boolean sVoiceCapable = true;
150
Santos Cordonc593d002015-06-03 15:41:15 -0700151 // TODO: Remove, no longer used.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700152 CdmaPhoneCallState cdmaPhoneCallState;
153
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700154 // The currently-active PUK entry activity and progress dialog.
155 // Normally, these are the Emergency Dialer and the subsequent
156 // progress dialog. null if there is are no such objects in
157 // the foreground.
158 private Activity mPUKEntryActivity;
159 private ProgressDialog mPUKEntryProgressDialog;
160
Jack Yu1a2fc352017-07-14 17:14:37 -0700161 private boolean mNoDataDueToRoaming = false;
Jack Yu953f9352017-05-18 14:41:06 -0700162
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700163 private WakeState mWakeState = WakeState.SLEEP;
164
165 private PowerManager mPowerManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700166 private PowerManager.WakeLock mWakeLock;
167 private PowerManager.WakeLock mPartialWakeLock;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700168 private KeyguardManager mKeyguardManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700169
170 private UpdateLock mUpdateLock;
171
Jack Yu1a2fc352017-07-14 17:14:37 -0700172 private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
173 private final LocalLog mDataRoamingNotifLog = new LocalLog(50);
174
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700175 // Broadcast receiver for various intent broadcasts (see onCreate())
176 private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver();
Brad Ebinger533c6c12017-08-02 11:38:48 -0700177 // Broadcast receiver for SIP based intents (see onCreate())
Brad Ebinger28626122017-08-10 14:13:35 -0700178 private final SipReceiver mSipReceiver = new SipReceiver();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700179
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -0700180 private final CarrierVvmPackageInstalledReceiver mCarrierVvmPackageInstalledReceiver =
181 new CarrierVvmPackageInstalledReceiver();
182
Jack Yu1a2fc352017-07-14 17:14:37 -0700183 private final SettingsObserver mSettingsObserver;
184
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700185 Handler mHandler = new Handler() {
186 @Override
187 public void handleMessage(Message msg) {
188 PhoneConstants.State phoneState;
Jack Yu1a2fc352017-07-14 17:14:37 -0700189 if (VDBG) Log.v(LOG_TAG, "event=" + msg.what);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700190 switch (msg.what) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700191 // TODO: This event should be handled by the lock screen, just
192 // like the "SIM missing" and "Sim locked" cases (bug 1804111).
193 case EVENT_SIM_NETWORK_LOCKED:
Jonathan Basseri9504c6b2015-06-04 14:23:32 -0700194 if (getCarrierConfig().getBoolean(
195 CarrierConfigManager.KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL)) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700196 // Some products don't have the concept of a "SIM network lock"
197 Log.i(LOG_TAG, "Ignoring EVENT_SIM_NETWORK_LOCKED event; "
Eric Erfanian945409f2018-02-21 19:26:15 +0000198 + "not showing 'SIM network unlock' PIN entry screen");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700199 } else {
200 // Normal case: show the "SIM network unlock" PIN entry screen.
201 // The user won't be able to do anything else until
202 // they enter a valid SIM network PIN.
203 Log.i(LOG_TAG, "show sim depersonal panel");
Biljana Maneva96291112018-01-30 13:12:59 +0800204 Phone phone = (Phone) ((AsyncResult) msg.obj).userObj;
205 IccNetworkDepersonalizationPanel.showDialog(phone);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700206 }
207 break;
208
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700209 case EVENT_DATA_ROAMING_DISCONNECTED:
Pengquan Meng8783d932017-10-16 14:57:40 -0700210 notificationMgr.showDataDisconnectedRoaming(msg.arg1);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700211 break;
212
213 case EVENT_DATA_ROAMING_OK:
214 notificationMgr.hideDataDisconnectedRoaming();
215 break;
216
217 case MMI_COMPLETE:
218 onMMIComplete((AsyncResult) msg.obj);
219 break;
220
221 case MMI_CANCEL:
Stuart Scottdcf40a92014-12-09 10:45:01 -0800222 PhoneUtils.cancelMmiCode(mCM.getFgPhone());
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700223 break;
224
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700225 case EVENT_SIM_STATE_CHANGED:
226 // Marks the event where the SIM goes into ready state.
227 // Right now, this is only used for the PUK-unlocking
228 // process.
229 if (msg.obj.equals(IccCardConstants.INTENT_VALUE_ICC_READY)) {
230 // when the right event is triggered and there
231 // are UI objects in the foreground, we close
232 // them to display the lock panel.
233 if (mPUKEntryActivity != null) {
234 mPUKEntryActivity.finish();
235 mPUKEntryActivity = null;
236 }
237 if (mPUKEntryProgressDialog != null) {
238 mPUKEntryProgressDialog.dismiss();
239 mPUKEntryProgressDialog = null;
240 }
241 }
242 break;
243
244 case EVENT_UNSOL_CDMA_INFO_RECORD:
245 //TODO: handle message here;
246 break;
Brad Ebinger3fa43462016-04-12 16:06:48 -0700247 case EVENT_RESTART_SIP:
248 // This should only run if the Phone process crashed and was restarted. We do
249 // not want this running if the device is still in the FBE encrypted state.
Brad Ebinger28626122017-08-10 14:13:35 -0700250 // This is the same procedure that is triggered in the SipIncomingCallReceiver
Brad Ebinger3fa43462016-04-12 16:06:48 -0700251 // upon BOOT_COMPLETED.
252 UserManager userManager = UserManager.get(sMe);
253 if (userManager != null && userManager.isUserUnlocked()) {
254 SipUtil.startSipService();
255 }
256 break;
Jack Yu1a2fc352017-07-14 17:14:37 -0700257 case EVENT_DATA_ROAMING_SETTINGS_CHANGED:
258 case EVENT_MOBILE_DATA_SETTINGS_CHANGED:
259 updateDataRoamingStatus();
260 break;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700261 }
262 }
263 };
264
265 public PhoneGlobals(Context context) {
266 super(context);
267 sMe = this;
Jack Yu1a2fc352017-07-14 17:14:37 -0700268 mSettingsObserver = new SettingsObserver(context, mHandler);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700269 }
270
271 public void onCreate() {
272 if (VDBG) Log.v(LOG_TAG, "onCreate()...");
273
274 ContentResolver resolver = getContentResolver();
275
276 // Cache the "voice capable" flag.
277 // This flag currently comes from a resource (which is
278 // overrideable on a per-product basis):
279 sVoiceCapable =
280 getResources().getBoolean(com.android.internal.R.bool.config_voice_capable);
281 // ...but this might eventually become a PackageManager "system
282 // feature" instead, in which case we'd do something like:
283 // sVoiceCapable =
284 // getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_VOICE_CALLS);
285
Stuart Scottdcf40a92014-12-09 10:45:01 -0800286 if (mCM == null) {
Nathan Harold0db5c5e2019-01-22 20:18:56 -0800287 // Initialize DebugEventReporter early so that it can be used
288 DebugEventReporter.initialize(this);
289
Youming Ye47a6adc2018-11-19 15:33:36 -0800290 // Inject telephony component factory if configured using other jars.
291 XmlResourceParser parser = getResources().getXml(R.xml.telephony_injection);
292 TelephonyComponentFactory.getInstance().injectTheComponentFactory(parser);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700293 // Initialize the telephony framework
294 PhoneFactory.makeDefaultPhones(this);
295
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700296 // Start TelephonyDebugService After the default phone is created.
297 Intent intent = new Intent(this, TelephonyDebugService.class);
298 startService(intent);
299
300 mCM = CallManager.getInstance();
Stuart Scottdcf40a92014-12-09 10:45:01 -0800301 for (Phone phone : PhoneFactory.getPhones()) {
302 mCM.registerPhone(phone);
Stuart Scottdcf40a92014-12-09 10:45:01 -0800303 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700304
305 // Create the NotificationMgr singleton, which is used to display
306 // status bar icons and control other status bar behavior.
307 notificationMgr = NotificationMgr.init(this);
308
Brad Ebinger3fa43462016-04-12 16:06:48 -0700309 // If PhoneGlobals has crashed and is being restarted, then restart.
310 mHandler.sendEmptyMessage(EVENT_RESTART_SIP);
311
Anthony Lee03ebdfc2015-07-27 08:12:02 -0700312 // Create an instance of CdmaPhoneCallState and initialize it to IDLE
313 cdmaPhoneCallState = new CdmaPhoneCallState();
314 cdmaPhoneCallState.CdmaPhoneCallStateInit();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700315
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700316 // before registering for phone state changes
317 mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
318 mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, LOG_TAG);
319 // lock used to keep the processor awake, when we don't care for the display.
320 mPartialWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
321 | PowerManager.ON_AFTER_RELEASE, LOG_TAG);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700322
323 mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
324
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700325 // Get UpdateLock to suppress system-update related events (e.g. dialog show-up)
326 // during phone calls.
327 mUpdateLock = new UpdateLock("phone");
328
329 if (DBG) Log.d(LOG_TAG, "onCreate: mUpdateLock: " + mUpdateLock);
330
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700331 // Create the CallerInfoCache singleton, which remembers custom ring tone and
332 // send-to-voicemail settings.
333 //
334 // The asynchronous caching will start just after this call.
335 callerInfoCache = CallerInfoCache.init(this);
336
Nazanin Bakhshi2f2cc692018-12-11 15:15:39 -0800337 phoneMgr = PhoneInterfaceManager.init(this);
Santos Cordon406c0342013-08-28 00:07:47 -0700338
Jonathan Basseri6465afd2015-02-25 13:05:57 -0800339 configLoader = CarrierConfigLoader.init(this);
340
Jack Yu1a2fc352017-07-14 17:14:37 -0700341 // Create the CallNotifier singleton, which handles
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700342 // asynchronous events from the telephony layer (like
343 // launching the incoming-call UI when an incoming call comes
344 // in.)
Brad Ebingera9c6b6d2016-01-07 17:24:16 -0800345 notifier = CallNotifier.init(this);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700346
Stuart Scottdcf40a92014-12-09 10:45:01 -0800347 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700348
349 // register for MMI/USSD
350 mCM.registerForMmiComplete(mHandler, MMI_COMPLETE, null);
351
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700352 // Register for misc other intent broadcasts.
353 IntentFilter intentFilter =
354 new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700355 intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
356 intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
357 intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
358 intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
Jack Yu1a2fc352017-07-14 17:14:37 -0700359 intentFilter.addAction(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
360 intentFilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700361 registerReceiver(mReceiver, intentFilter);
362
Brad Ebinger533c6c12017-08-02 11:38:48 -0700363 IntentFilter sipIntentFilter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
Brad Ebinger533c6c12017-08-02 11:38:48 -0700364 sipIntentFilter.addAction(SipManager.ACTION_SIP_SERVICE_UP);
365 sipIntentFilter.addAction(SipManager.ACTION_SIP_CALL_OPTION_CHANGED);
366 sipIntentFilter.addAction(SipManager.ACTION_SIP_REMOVE_PHONE);
Brad Ebinger28626122017-08-10 14:13:35 -0700367 registerReceiver(mSipReceiver, sipIntentFilter);
Brad Ebinger533c6c12017-08-02 11:38:48 -0700368
Ta-wei Yenf0a71bc2017-05-17 12:28:28 -0700369 mCarrierVvmPackageInstalledReceiver.register(this);
370
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700371 //set the default values for the preferences in the phone.
pkanward702e542017-02-08 15:44:54 -0800372 PreferenceManager.setDefaultValues(this, R.xml.network_setting_fragment, false);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700373
374 PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700375 }
376
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700377 // XXX pre-load the SimProvider so that it's ready
378 resolver.getType(Uri.parse("content://icc/adn"));
379
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700380 // TODO: Register for Cdma Information Records
381 // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null);
382
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700383 // Read HAC settings and configure audio hardware
384 if (getResources().getBoolean(R.bool.hac_enabled)) {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800385 int hac = android.provider.Settings.System.getInt(
386 getContentResolver(),
387 android.provider.Settings.System.HEARING_AID,
388 0);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700389 AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
Andrew Leefb7f92e2015-02-26 16:23:32 -0800390 audioManager.setParameter(SettingsConstants.HAC_KEY,
391 hac == SettingsConstants.HAC_ENABLED
392 ? SettingsConstants.HAC_VAL_ON : SettingsConstants.HAC_VAL_OFF);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700393 }
Santos Cordonff506f52013-11-21 19:13:19 -0800394 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700395
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700396 /**
397 * Returns the singleton instance of the PhoneApp.
398 */
Sailesh Nepal1eaf22b2014-02-22 17:00:49 -0800399 public static PhoneGlobals getInstance() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700400 if (sMe == null) {
401 throw new IllegalStateException("No PhoneGlobals here!");
402 }
403 return sMe;
404 }
405
406 /**
Stuart Scottdcf40a92014-12-09 10:45:01 -0800407 * Returns the default phone.
408 *
Andrew Lee385019f2014-11-24 14:19:50 -0800409 * WARNING: This method should be used carefully, now that there may be multiple phones.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700410 */
Andrew Lee83383e42014-10-31 12:42:28 -0700411 public static Phone getPhone() {
Stuart Scottdcf40a92014-12-09 10:45:01 -0800412 return PhoneFactory.getDefaultPhone();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700413 }
414
Andrew Lee2fcb6c32014-12-04 14:52:35 -0800415 public static Phone getPhone(int subId) {
416 return PhoneFactory.getPhone(SubscriptionManager.getPhoneId(subId));
Andrew Lee385019f2014-11-24 14:19:50 -0800417 }
418
Santos Cordonde10b752013-09-19 04:11:33 -0700419 /* package */ CallManager getCallManager() {
420 return mCM;
421 }
422
Chris Manton4e9fa912015-06-19 11:26:57 -0700423 public PersistableBundle getCarrierConfig() {
Shishir Agrawald3480e02016-01-25 13:05:49 -0800424 return getCarrierConfigForSubId(SubscriptionManager.getDefaultSubscriptionId());
Jonathan Basseri89b0ab42015-05-01 10:52:40 -0700425 }
426
Chris Manton4e9fa912015-06-19 11:26:57 -0700427 public PersistableBundle getCarrierConfigForSubId(int subId) {
Malcolm Chen6d3d6b32018-03-01 13:58:03 -0800428 return configLoader.getConfigForSubId(subId, getOpPackageName());
Junda Liu605148f2015-04-28 15:23:40 -0700429 }
430
Jack Yu1a2fc352017-07-14 17:14:37 -0700431 private void registerSettingsObserver() {
432 mSettingsObserver.unobserve();
433 String dataRoamingSetting = Settings.Global.DATA_ROAMING;
434 String mobileDataSetting = Settings.Global.MOBILE_DATA;
435 if (TelephonyManager.getDefault().getSimCount() > 1) {
436 int subId = mDefaultDataSubId;
437 if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
438 dataRoamingSetting += subId;
439 mobileDataSetting += subId;
440 }
441 }
442
443 // Listen for user data roaming setting changed event
444 mSettingsObserver.observe(Settings.Global.getUriFor(dataRoamingSetting),
445 EVENT_DATA_ROAMING_SETTINGS_CHANGED);
446
447 // Listen for mobile data setting changed event
448 mSettingsObserver.observe(Settings.Global.getUriFor(mobileDataSetting),
449 EVENT_MOBILE_DATA_SETTINGS_CHANGED);
450 }
451
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700452 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700453 * Sets the activity responsible for un-PUK-blocking the device
454 * so that we may close it when we receive a positive result.
455 * mPUKEntryActivity is also used to indicate to the device that
456 * we are trying to un-PUK-lock the phone. In other words, iff
457 * it is NOT null, then we are trying to unlock and waiting for
458 * the SIM to move to READY state.
459 *
460 * @param activity is the activity to close when PUK has
461 * finished unlocking. Can be set to null to indicate the unlock
462 * or SIM READYing process is over.
463 */
464 void setPukEntryActivity(Activity activity) {
465 mPUKEntryActivity = activity;
466 }
467
468 Activity getPUKEntryActivity() {
469 return mPUKEntryActivity;
470 }
471
472 /**
473 * Sets the dialog responsible for notifying the user of un-PUK-
474 * blocking - SIM READYing progress, so that we may dismiss it
475 * when we receive a positive result.
476 *
477 * @param dialog indicates the progress dialog informing the user
478 * of the state of the device. Dismissed upon completion of
479 * READYing process
480 */
481 void setPukEntryProgressDialog(ProgressDialog dialog) {
482 mPUKEntryProgressDialog = dialog;
483 }
484
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700485 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700486 * If we are not currently keeping the screen on, then poke the power
487 * manager to wake up the screen for the user activity timeout duration.
488 */
489 /* package */ void wakeUpScreen() {
490 synchronized (this) {
491 if (mWakeState == WakeState.SLEEP) {
492 if (DBG) Log.d(LOG_TAG, "pulse screen lock");
Dianne Hackborn148769b2015-07-13 17:55:47 -0700493 mPowerManager.wakeUp(SystemClock.uptimeMillis(), "android.phone:WAKE");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700494 }
495 }
496 }
497
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700498 KeyguardManager getKeyguardManager() {
499 return mKeyguardManager;
500 }
501
502 private void onMMIComplete(AsyncResult r) {
503 if (VDBG) Log.d(LOG_TAG, "onMMIComplete()...");
504 MmiCode mmiCode = (MmiCode) r.result;
Stuart Scottdcf40a92014-12-09 10:45:01 -0800505 PhoneUtils.displayMMIComplete(mmiCode.getPhone(), getInstance(), mmiCode, null, null);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700506 }
507
fionaxu80126972017-02-01 17:01:26 -0800508 private void initForNewRadioTechnology() {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700509 if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology...");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700510 notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700511 }
512
Chris Mantona09f3632016-02-09 14:48:42 -0800513 private void handleAirplaneModeChange(Context context, int newMode) {
514 int cellState = Settings.Global.getInt(context.getContentResolver(),
515 Settings.Global.CELL_ON, PhoneConstants.CELL_ON_FLAG);
516 boolean isAirplaneNewlyOn = (newMode == 1);
517 switch (cellState) {
518 case PhoneConstants.CELL_OFF_FLAG:
519 // Airplane mode does not affect the cell radio if user
520 // has turned it off.
521 break;
522 case PhoneConstants.CELL_ON_FLAG:
523 maybeTurnCellOff(context, isAirplaneNewlyOn);
524 break;
525 case PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG:
526 maybeTurnCellOn(context, isAirplaneNewlyOn);
527 break;
528 }
529 }
530
531 /*
532 * Returns true if the radio must be turned off when entering airplane mode.
533 */
534 private boolean isCellOffInAirplaneMode(Context context) {
535 String airplaneModeRadios = Settings.Global.getString(context.getContentResolver(),
536 Settings.Global.AIRPLANE_MODE_RADIOS);
537 return airplaneModeRadios == null
538 || airplaneModeRadios.contains(Settings.Global.RADIO_CELL);
539 }
540
541 private void setRadioPowerOff(Context context) {
542 Log.i(LOG_TAG, "Turning radio off - airplane");
543 Settings.Global.putInt(context.getContentResolver(), Settings.Global.CELL_ON,
Eric Erfanian945409f2018-02-21 19:26:15 +0000544 PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG);
Sooraj Sasindran798bafa2017-04-03 22:49:00 -0700545 SystemProperties.set("persist.radio.airplane_mode_on", "1");
Chris Mantona09f3632016-02-09 14:48:42 -0800546 Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT, 0);
547 PhoneUtils.setRadioPower(false);
548 }
549
550 private void setRadioPowerOn(Context context) {
551 Log.i(LOG_TAG, "Turning radio on - airplane");
552 Settings.Global.putInt(context.getContentResolver(), Settings.Global.CELL_ON,
553 PhoneConstants.CELL_ON_FLAG);
554 Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT,
555 1);
Sooraj Sasindran798bafa2017-04-03 22:49:00 -0700556 SystemProperties.set("persist.radio.airplane_mode_on", "0");
Chris Mantona09f3632016-02-09 14:48:42 -0800557 PhoneUtils.setRadioPower(true);
558 }
559
560 private void maybeTurnCellOff(Context context, boolean isAirplaneNewlyOn) {
561 if (isAirplaneNewlyOn) {
Santos Cordone18902f2016-03-22 17:16:04 -0700562 // If we are trying to turn off the radio, make sure there are no active
563 // emergency calls. If there are, switch airplane mode back to off.
Tyler Gunn900d8fd2018-09-21 09:22:12 -0700564 TelecomManager tm = (TelecomManager) context.getSystemService(TELECOM_SERVICE);
565
566 if (tm != null && tm.isInEmergencyCall()) {
Santos Cordone18902f2016-03-22 17:16:04 -0700567 // Switch airplane mode back to off.
568 ConnectivityManager.from(this).setAirplaneMode(false);
569 Toast.makeText(this, R.string.radio_off_during_emergency_call, Toast.LENGTH_LONG)
570 .show();
571 Log.i(LOG_TAG, "Ignoring airplane mode: emergency call. Turning airplane off");
Chris Mantona09f3632016-02-09 14:48:42 -0800572 } else if (isCellOffInAirplaneMode(context)) {
573 setRadioPowerOff(context);
Santos Cordone18902f2016-03-22 17:16:04 -0700574 } else {
Chris Mantona09f3632016-02-09 14:48:42 -0800575 Log.i(LOG_TAG, "Ignoring airplane mode: settings prevent cell radio power off");
Santos Cordone18902f2016-03-22 17:16:04 -0700576 }
Chris Mantona09f3632016-02-09 14:48:42 -0800577 }
578 }
579
580 private void maybeTurnCellOn(Context context, boolean isAirplaneNewlyOn) {
581 if (!isAirplaneNewlyOn) {
582 setRadioPowerOn(context);
Santos Cordone18902f2016-03-22 17:16:04 -0700583 }
584 }
585
Santos Cordon593ab382013-08-06 21:58:23 -0700586 /**
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700587 * Receiver for misc intent broadcasts the Phone app cares about.
588 */
589 private class PhoneAppBroadcastReceiver extends BroadcastReceiver {
590 @Override
591 public void onReceive(Context context, Intent intent) {
592 String action = intent.getAction();
593 if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
Santos Cordone18902f2016-03-22 17:16:04 -0700594 int airplaneMode = Settings.Global.getInt(getContentResolver(),
595 Settings.Global.AIRPLANE_MODE_ON, AIRPLANE_OFF);
596 // Treat any non-OFF values as ON.
597 if (airplaneMode != AIRPLANE_OFF) {
598 airplaneMode = AIRPLANE_ON;
599 }
Chris Mantona09f3632016-02-09 14:48:42 -0800600 handleAirplaneModeChange(context, airplaneMode);
Amit Mahajanf5d92c82018-11-02 17:44:40 -0700601 } else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
602 // re-register as it may be a new IccCard
603 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY,
604 SubscriptionManager.INVALID_PHONE_INDEX);
605 if (SubscriptionManager.isValidPhoneId(phoneId)) {
606 PhoneUtils.unregisterIccStatus(mHandler, phoneId);
607 PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED, phoneId);
608 }
609 if (mPUKEntryActivity != null) {
610 // if an attempt to un-PUK-lock the device was made, while we're
611 // receiving this state change notification, notify the handler.
612 // NOTE: This is ONLY triggered if an attempt to un-PUK-lock has
613 // been attempted.
614 mHandler.sendMessage(mHandler.obtainMessage(EVENT_SIM_STATE_CHANGED,
615 intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE)));
616 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700617 } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) {
618 String newPhone = intent.getStringExtra(PhoneConstants.PHONE_NAME_KEY);
fionaxu80126972017-02-01 17:01:26 -0800619 Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active.");
620 initForNewRadioTechnology();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700621 } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) {
622 handleServiceStateChanged(intent);
623 } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530624 int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY, 0);
Srikanth Chintala079912a2016-03-03 16:35:01 +0530625 phoneInEcm = PhoneFactory.getPhone(phoneId);
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530626 Log.d(LOG_TAG, "Emergency Callback Mode. phoneId:" + phoneId);
627 if (phoneInEcm != null) {
628 if (TelephonyCapabilities.supportsEcm(phoneInEcm)) {
629 Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp.");
630 // Start Emergency Callback Mode service
631 if (intent.getBooleanExtra("phoneinECMState", false)) {
632 context.startService(new Intent(context,
633 EmergencyCallbackModeService.class));
634 } else {
635 phoneInEcm = null;
636 }
637 } else {
638 // It doesn't make sense to get ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
639 // on a device that doesn't support ECM in the first place.
640 Log.e(LOG_TAG, "Got ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, but "
641 + "ECM isn't supported for phone: " + phoneInEcm.getPhoneName());
642 phoneInEcm = null;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700643 }
644 } else {
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530645 Log.w(LOG_TAG, "phoneInEcm is null.");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700646 }
Jack Yu1a2fc352017-07-14 17:14:37 -0700647 } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) {
648 // Roaming status could be overridden by carrier config, so we need to update it.
649 if (VDBG) Log.v(LOG_TAG, "carrier config changed.");
650 updateDataRoamingStatus();
651 } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
652 // We also need to pay attention when default data subscription changes.
653 if (VDBG) Log.v(LOG_TAG, "default data sub changed.");
654 mDefaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
655 registerSettingsObserver();
656 Phone phone = getPhone(mDefaultDataSubId);
657 if (phone != null) {
658 updateDataRoamingStatus();
659 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700660 }
661 }
662 }
663
Brad Ebinger28626122017-08-10 14:13:35 -0700664 private class SipReceiver extends BroadcastReceiver {
665
666 @Override
667 public void onReceive(Context context, Intent intent) {
668 String action = intent.getAction();
669
670 SipAccountRegistry sipAccountRegistry = SipAccountRegistry.getInstance();
671 if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
672 SipUtil.startSipService();
673 } else if (action.equals(SipManager.ACTION_SIP_SERVICE_UP)
674 || action.equals(SipManager.ACTION_SIP_CALL_OPTION_CHANGED)) {
675 sipAccountRegistry.setup(context);
676 } else if (action.equals(SipManager.ACTION_SIP_REMOVE_PHONE)) {
677 if (DBG) {
678 Log.d(LOG_TAG, "SIP_REMOVE_PHONE "
679 + intent.getStringExtra(SipManager.EXTRA_LOCAL_URI));
680 }
681 sipAccountRegistry.removeSipProfile(intent.getStringExtra(
682 SipManager.EXTRA_LOCAL_URI));
683 } else {
684 if (DBG) Log.d(LOG_TAG, "onReceive, action not processed: " + action);
685 }
686 }
687 }
688
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700689 private void handleServiceStateChanged(Intent intent) {
690 /**
691 * This used to handle updating EriTextWidgetProvider this routine
692 * and and listening for ACTION_SERVICE_STATE_CHANGED intents could
693 * be removed. But leaving just in case it might be needed in the near
694 * future.
695 */
696
Jack Yu1a2fc352017-07-14 17:14:37 -0700697 if (VDBG) Log.v(LOG_TAG, "handleServiceStateChanged");
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700698 // If service just returned, start sending out the queued messages
Santos Cordonc593d002015-06-03 15:41:15 -0700699 Bundle extras = intent.getExtras();
700 if (extras != null) {
701 ServiceState ss = ServiceState.newFromBundle(extras);
702 if (ss != null) {
703 int state = ss.getState();
Jayachandran C2ef9a482017-05-12 22:07:47 -0700704 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
705 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
706 notificationMgr.updateNetworkSelection(state, subId);
Jack Yu1a2fc352017-07-14 17:14:37 -0700707
708 if (VDBG) {
709 Log.v(LOG_TAG, "subId=" + subId + ",mDefaultDataSubId="
710 + mDefaultDataSubId + ",ss roaming=" + ss.getDataRoaming());
711 }
712 if (subId == mDefaultDataSubId) {
713 updateDataRoamingStatus();
714 }
Santos Cordonc593d002015-06-03 15:41:15 -0700715 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700716 }
717 }
718
Jack Yu1a2fc352017-07-14 17:14:37 -0700719 /**
720 * When roaming, if mobile data cannot be established due to data roaming not enabled, we need
721 * to notify the user so they can enable it through settings. Vise versa if the condition
722 * changes, we need to dismiss the notification.
723 */
724 private void updateDataRoamingStatus() {
725 if (VDBG) Log.v(LOG_TAG, "updateDataRoamingStatus");
726 Phone phone = getPhone(mDefaultDataSubId);
727 if (phone == null) {
728 Log.w(LOG_TAG, "Can't get phone with sub id = " + mDefaultDataSubId);
729 return;
730 }
731
732 DataConnectionReasons reasons = new DataConnectionReasons();
Jack Yu311536f2018-11-26 11:20:48 -0800733 boolean dataAllowed = phone.isDataAllowed(ApnSetting.TYPE_DEFAULT, reasons);
Jack Yu1a2fc352017-07-14 17:14:37 -0700734 mDataRoamingNotifLog.log("dataAllowed=" + dataAllowed + ", reasons=" + reasons);
735 if (VDBG) Log.v(LOG_TAG, "dataAllowed=" + dataAllowed + ", reasons=" + reasons);
736 if (!mNoDataDueToRoaming
737 && !dataAllowed
738 && reasons.containsOnly(DataDisallowedReasonType.ROAMING_DISABLED)) {
739 // If the only reason of no data is data roaming disabled, then we notify the user
740 // so the user can turn on data roaming.
741 mNoDataDueToRoaming = true;
742 Log.d(LOG_TAG, "Show roaming disconnected notification");
743 mDataRoamingNotifLog.log("Show");
Pengquan Meng8783d932017-10-16 14:57:40 -0700744 Message msg = mHandler.obtainMessage(EVENT_DATA_ROAMING_DISCONNECTED);
745 msg.arg1 = mDefaultDataSubId;
746 msg.sendToTarget();
Jack Yu1a2fc352017-07-14 17:14:37 -0700747 } else if (mNoDataDueToRoaming && (dataAllowed
748 || !reasons.containsOnly(DataDisallowedReasonType.ROAMING_DISABLED))) {
749 // Otherwise dismiss the notification we showed earlier.
750 mNoDataDueToRoaming = false;
751 Log.d(LOG_TAG, "Dismiss roaming disconnected notification");
752 mDataRoamingNotifLog.log("Hide. data allowed=" + dataAllowed + ", reasons=" + reasons);
753 mHandler.sendEmptyMessage(EVENT_DATA_ROAMING_OK);
754 }
755 }
756
Sandeep Kuntade73a6a2014-10-15 18:45:56 +0530757 public Phone getPhoneInEcm() {
758 return phoneInEcm;
759 }
760
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700761 /**
Tyler Gunn9c1071f2014-12-09 10:07:54 -0800762 * Triggers a refresh of the message waiting (voicemail) indicator.
763 *
764 * @param subId the subscription id we should refresh the notification for.
765 */
766 public void refreshMwiIndicator(int subId) {
767 notificationMgr.refreshMwi(subId);
768 }
769
770 /**
Pengquan Mengdd9ac822018-09-20 15:25:35 -0700771 * Called when the network selection on the subscription {@code subId} is changed by the user.
772 *
773 * @param subId the subscription id.
774 */
775 public void onNetworkSelectionChanged(int subId) {
776 Phone phone = getPhone(subId);
777 if (phone != null) {
778 notificationMgr.updateNetworkSelection(phone.getServiceState().getState(), subId);
779 } else {
780 Log.w(LOG_TAG, "onNetworkSelectionChanged on null phone, subId: " + subId);
781 }
782 }
783
784 /**
Jack Yu1a2fc352017-07-14 17:14:37 -0700785 * Dump the state of the object, add calls to other objects as desired.
786 *
787 * @param fd File descriptor
788 * @param printWriter Print writer
789 * @param args Arguments
790 */
791 public void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) {
792 IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " ");
793 pw.println("------- PhoneGlobals -------");
794 pw.increaseIndent();
795 pw.println("mNoDataDueToRoaming=" + mNoDataDueToRoaming);
796 pw.println("mDefaultDataSubId=" + mDefaultDataSubId);
797 pw.println("mDataRoamingNotifLog:");
798 pw.increaseIndent();
799 mDataRoamingNotifLog.dump(fd, pw, args);
800 pw.decreaseIndent();
801 pw.decreaseIndent();
802 pw.println("------- End PhoneGlobals -------");
803 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700804}