Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.phone; |
| 18 | |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 19 | import android.annotation.IntDef; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 20 | import android.app.Activity; |
| 21 | import android.app.KeyguardManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 22 | import android.app.ProgressDialog; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 23 | import android.content.BroadcastReceiver; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 24 | import android.content.ContentResolver; |
| 25 | import android.content.Context; |
| 26 | import android.content.ContextWrapper; |
| 27 | import android.content.Intent; |
| 28 | import android.content.IntentFilter; |
Brad Ebinger | 05f52c2 | 2019-12-05 13:03:21 -0800 | [diff] [blame] | 29 | import android.content.pm.PackageManager; |
Youming Ye | 47a6adc | 2018-11-19 15:33:36 -0800 | [diff] [blame] | 30 | import android.content.res.XmlResourceParser; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 31 | import android.media.AudioManager; |
Santos Cordon | e18902f | 2016-03-22 17:16:04 -0700 | [diff] [blame] | 32 | import android.net.ConnectivityManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 33 | import android.net.Uri; |
Brad Ebinger | 533c6c1 | 2017-08-02 11:38:48 -0700 | [diff] [blame] | 34 | import android.net.sip.SipManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 35 | import android.os.AsyncResult; |
Junda Liu | 605148f | 2015-04-28 15:23:40 -0700 | [diff] [blame] | 36 | import android.os.Bundle; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 37 | import android.os.Handler; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 38 | import android.os.Message; |
Jonathan Basseri | c31f1f3 | 2015-05-12 10:13:03 -0700 | [diff] [blame] | 39 | import android.os.PersistableBundle; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 40 | import android.os.PowerManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 41 | import android.os.SystemProperties; |
Brad Ebinger | 3fa4346 | 2016-04-12 16:06:48 -0700 | [diff] [blame] | 42 | import android.os.UserManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 43 | import android.preference.PreferenceManager; |
Sanket Padawe | 4c69923 | 2016-02-09 11:07:22 -0800 | [diff] [blame] | 44 | import android.provider.Settings; |
Meng Wang | 6130762 | 2019-10-23 14:08:43 -0700 | [diff] [blame] | 45 | import android.sysprop.TelephonyProperties; |
Tyler Gunn | 900d8fd | 2018-09-21 09:22:12 -0700 | [diff] [blame] | 46 | import android.telecom.TelecomManager; |
Nathan Harold | f9df6ea | 2019-03-08 11:54:22 -0800 | [diff] [blame] | 47 | import android.telephony.AnomalyReporter; |
Junda Liu | 12f7d80 | 2015-05-01 12:06:44 -0700 | [diff] [blame] | 48 | import android.telephony.CarrierConfigManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 49 | import android.telephony.ServiceState; |
chen xu | baf9fe5 | 2019-07-02 17:28:24 -0700 | [diff] [blame] | 50 | import android.telephony.SubscriptionInfo; |
Andrew Lee | 385019f | 2014-11-24 14:19:50 -0800 | [diff] [blame] | 51 | import android.telephony.SubscriptionManager; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 52 | import android.telephony.TelephonyManager; |
Jack Yu | 311536f | 2018-11-26 11:20:48 -0800 | [diff] [blame] | 53 | import android.telephony.data.ApnSetting; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 54 | import android.util.LocalLog; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 55 | import android.util.Log; |
Santos Cordon | e18902f | 2016-03-22 17:16:04 -0700 | [diff] [blame] | 56 | import android.widget.Toast; |
Ta-wei Yen | b29425b | 2016-09-21 17:28:14 -0700 | [diff] [blame] | 57 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 58 | import com.android.internal.telephony.CallManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 59 | import com.android.internal.telephony.IccCardConstants; |
| 60 | import com.android.internal.telephony.MmiCode; |
| 61 | import com.android.internal.telephony.Phone; |
| 62 | import com.android.internal.telephony.PhoneConstants; |
| 63 | import com.android.internal.telephony.PhoneFactory; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 64 | import com.android.internal.telephony.SettingsObserver; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 65 | import com.android.internal.telephony.TelephonyCapabilities; |
Youming Ye | 47a6adc | 2018-11-19 15:33:36 -0800 | [diff] [blame] | 66 | import com.android.internal.telephony.TelephonyComponentFactory; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 67 | import com.android.internal.telephony.TelephonyIntents; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 68 | import com.android.internal.telephony.dataconnection.DataConnectionReasons; |
| 69 | import com.android.internal.telephony.dataconnection.DataConnectionReasons.DataDisallowedReasonType; |
Brad Ebinger | 05f52c2 | 2019-12-05 13:03:21 -0800 | [diff] [blame] | 70 | import com.android.internal.telephony.ims.ImsResolver; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 71 | import com.android.internal.util.IndentingPrintWriter; |
Andrew Lee | fb7f92e | 2015-02-26 16:23:32 -0800 | [diff] [blame] | 72 | import com.android.phone.settings.SettingsConstants; |
Ta-wei Yen | f0a71bc | 2017-05-17 12:28:28 -0700 | [diff] [blame] | 73 | import com.android.phone.vvm.CarrierVvmPackageInstalledReceiver; |
James.cf Lin | c9f35a4 | 2020-01-15 02:35:22 +0800 | [diff] [blame^] | 74 | import com.android.services.telephony.rcs.TelephonyRcsService; |
Brad Ebinger | 2862612 | 2017-08-10 14:13:35 -0700 | [diff] [blame] | 75 | import com.android.services.telephony.sip.SipAccountRegistry; |
Brad Ebinger | 3fa4346 | 2016-04-12 16:06:48 -0700 | [diff] [blame] | 76 | import com.android.services.telephony.sip.SipUtil; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 77 | |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 78 | import java.io.FileDescriptor; |
| 79 | import java.io.PrintWriter; |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 80 | import java.lang.annotation.Retention; |
| 81 | import java.lang.annotation.RetentionPolicy; |
chen xu | baf9fe5 | 2019-07-02 17:28:24 -0700 | [diff] [blame] | 82 | import java.util.List; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 83 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 84 | /** |
| 85 | * Global state for the telephony subsystem when running in the primary |
| 86 | * phone process. |
| 87 | */ |
Sailesh Nepal | bf90054 | 2014-07-15 16:18:32 -0700 | [diff] [blame] | 88 | public class PhoneGlobals extends ContextWrapper { |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 89 | public static final String LOG_TAG = "PhoneGlobals"; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Phone app-wide debug level: |
| 93 | * 0 - no debug logging |
| 94 | * 1 - normal debug logging if ro.debuggable is set (which is true in |
| 95 | * "eng" and "userdebug" builds but not "user" builds) |
| 96 | * 2 - ultra-verbose debug logging |
| 97 | * |
| 98 | * Most individual classes in the phone app have a local DBG constant, |
| 99 | * typically set to |
| 100 | * (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1) |
| 101 | * or else |
| 102 | * (PhoneApp.DBG_LEVEL >= 2) |
| 103 | * depending on the desired verbosity. |
| 104 | * |
| 105 | * ***** DO NOT SUBMIT WITH DBG_LEVEL > 0 ************* |
| 106 | */ |
Andrew Lee | 88b51e2 | 2014-10-29 15:48:51 -0700 | [diff] [blame] | 107 | public static final int DBG_LEVEL = 0; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 108 | |
| 109 | private static final boolean DBG = |
| 110 | (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1); |
| 111 | private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2); |
| 112 | |
| 113 | // Message codes; see mHandler below. |
| 114 | private static final int EVENT_SIM_NETWORK_LOCKED = 3; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 115 | private static final int EVENT_SIM_STATE_CHANGED = 8; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 116 | private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10; |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 117 | private static final int EVENT_DATA_ROAMING_CONNECTED = 11; |
| 118 | private static final int EVENT_DATA_ROAMING_OK = 12; |
| 119 | private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 13; |
| 120 | private static final int EVENT_RESTART_SIP = 14; |
| 121 | private static final int EVENT_DATA_ROAMING_SETTINGS_CHANGED = 15; |
| 122 | private static final int EVENT_MOBILE_DATA_SETTINGS_CHANGED = 16; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 123 | |
| 124 | // The MMI codes are also used by the InCallScreen. |
| 125 | public static final int MMI_INITIATE = 51; |
| 126 | public static final int MMI_COMPLETE = 52; |
| 127 | public static final int MMI_CANCEL = 53; |
| 128 | // Don't use message codes larger than 99 here; those are reserved for |
| 129 | // the individual Activities of the Phone UI. |
| 130 | |
Santos Cordon | e18902f | 2016-03-22 17:16:04 -0700 | [diff] [blame] | 131 | public static final int AIRPLANE_ON = 1; |
| 132 | public static final int AIRPLANE_OFF = 0; |
| 133 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 134 | /** |
| 135 | * Allowable values for the wake lock code. |
| 136 | * SLEEP means the device can be put to sleep. |
| 137 | * PARTIAL means wake the processor, but we display can be kept off. |
| 138 | * FULL means wake both the processor and the display. |
| 139 | */ |
| 140 | public enum WakeState { |
| 141 | SLEEP, |
| 142 | PARTIAL, |
| 143 | FULL |
| 144 | } |
| 145 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 146 | private static PhoneGlobals sMe; |
| 147 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 148 | CallManager mCM; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 149 | CallNotifier notifier; |
| 150 | CallerInfoCache callerInfoCache; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 151 | NotificationMgr notificationMgr; |
Brad Ebinger | 05f52c2 | 2019-12-05 13:03:21 -0800 | [diff] [blame] | 152 | ImsResolver mImsResolver; |
James.cf Lin | c9f35a4 | 2020-01-15 02:35:22 +0800 | [diff] [blame^] | 153 | TelephonyRcsService mTelephonyRcsService; |
Andrew Lee | 9431b83 | 2015-03-09 18:46:45 -0700 | [diff] [blame] | 154 | public PhoneInterfaceManager phoneMgr; |
James.cf Lin | af3183c | 2019-10-24 00:59:00 +0800 | [diff] [blame] | 155 | public ImsRcsController imsRcsController; |
Jonathan Basseri | 6465afd | 2015-02-25 13:05:57 -0800 | [diff] [blame] | 156 | CarrierConfigLoader configLoader; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 157 | |
Sandeep Kunta | de73a6a | 2014-10-15 18:45:56 +0530 | [diff] [blame] | 158 | private Phone phoneInEcm; |
Santos Cordon | 63a8424 | 2013-07-23 13:32:52 -0700 | [diff] [blame] | 159 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 160 | static boolean sVoiceCapable = true; |
| 161 | |
Santos Cordon | c593d00 | 2015-06-03 15:41:15 -0700 | [diff] [blame] | 162 | // TODO: Remove, no longer used. |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 163 | CdmaPhoneCallState cdmaPhoneCallState; |
| 164 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 165 | // The currently-active PUK entry activity and progress dialog. |
| 166 | // Normally, these are the Emergency Dialer and the subsequent |
| 167 | // progress dialog. null if there is are no such objects in |
| 168 | // the foreground. |
| 169 | private Activity mPUKEntryActivity; |
| 170 | private ProgressDialog mPUKEntryProgressDialog; |
| 171 | |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 172 | /** @hide */ |
| 173 | @Retention(RetentionPolicy.SOURCE) |
| 174 | @IntDef(prefix = {"ROAMING_NOTIFICATION_"}, |
| 175 | value = { |
| 176 | ROAMING_NOTIFICATION_NO_NOTIFICATION, |
| 177 | ROAMING_NOTIFICATION_CONNECTED, |
| 178 | ROAMING_NOTIFICATION_DISCONNECTED}) |
| 179 | public @interface RoamingNotification {} |
| 180 | |
| 181 | private static final int ROAMING_NOTIFICATION_NO_NOTIFICATION = 0; |
| 182 | private static final int ROAMING_NOTIFICATION_CONNECTED = 1; |
| 183 | private static final int ROAMING_NOTIFICATION_DISCONNECTED = 2; |
| 184 | |
| 185 | @RoamingNotification |
| 186 | private int mPrevRoamingNotification = ROAMING_NOTIFICATION_NO_NOTIFICATION; |
Jack Yu | 953f935 | 2017-05-18 14:41:06 -0700 | [diff] [blame] | 187 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 188 | private WakeState mWakeState = WakeState.SLEEP; |
| 189 | |
| 190 | private PowerManager mPowerManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 191 | private PowerManager.WakeLock mWakeLock; |
| 192 | private PowerManager.WakeLock mPartialWakeLock; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 193 | private KeyguardManager mKeyguardManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 194 | |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 195 | private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
| 196 | private final LocalLog mDataRoamingNotifLog = new LocalLog(50); |
| 197 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 198 | // Broadcast receiver for various intent broadcasts (see onCreate()) |
| 199 | private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver(); |
Brad Ebinger | 533c6c1 | 2017-08-02 11:38:48 -0700 | [diff] [blame] | 200 | // Broadcast receiver for SIP based intents (see onCreate()) |
Brad Ebinger | 2862612 | 2017-08-10 14:13:35 -0700 | [diff] [blame] | 201 | private final SipReceiver mSipReceiver = new SipReceiver(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 202 | |
Ta-wei Yen | f0a71bc | 2017-05-17 12:28:28 -0700 | [diff] [blame] | 203 | private final CarrierVvmPackageInstalledReceiver mCarrierVvmPackageInstalledReceiver = |
| 204 | new CarrierVvmPackageInstalledReceiver(); |
| 205 | |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 206 | private final SettingsObserver mSettingsObserver; |
| 207 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 208 | Handler mHandler = new Handler() { |
| 209 | @Override |
| 210 | public void handleMessage(Message msg) { |
| 211 | PhoneConstants.State phoneState; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 212 | if (VDBG) Log.v(LOG_TAG, "event=" + msg.what); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 213 | switch (msg.what) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 214 | // TODO: This event should be handled by the lock screen, just |
| 215 | // like the "SIM missing" and "Sim locked" cases (bug 1804111). |
| 216 | case EVENT_SIM_NETWORK_LOCKED: |
Jonathan Basseri | 9504c6b | 2015-06-04 14:23:32 -0700 | [diff] [blame] | 217 | if (getCarrierConfig().getBoolean( |
| 218 | CarrierConfigManager.KEY_IGNORE_SIM_NETWORK_LOCKED_EVENTS_BOOL)) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 219 | // Some products don't have the concept of a "SIM network lock" |
| 220 | Log.i(LOG_TAG, "Ignoring EVENT_SIM_NETWORK_LOCKED event; " |
Eric Erfanian | 945409f | 2018-02-21 19:26:15 +0000 | [diff] [blame] | 221 | + "not showing 'SIM network unlock' PIN entry screen"); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 222 | } else { |
| 223 | // Normal case: show the "SIM network unlock" PIN entry screen. |
| 224 | // The user won't be able to do anything else until |
| 225 | // they enter a valid SIM network PIN. |
| 226 | Log.i(LOG_TAG, "show sim depersonal panel"); |
Biljana Maneva | 9629111 | 2018-01-30 13:12:59 +0800 | [diff] [blame] | 227 | Phone phone = (Phone) ((AsyncResult) msg.obj).userObj; |
| 228 | IccNetworkDepersonalizationPanel.showDialog(phone); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 229 | } |
| 230 | break; |
| 231 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 232 | case EVENT_DATA_ROAMING_DISCONNECTED: |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 233 | notificationMgr.showDataRoamingNotification(msg.arg1, false); |
| 234 | break; |
| 235 | |
| 236 | case EVENT_DATA_ROAMING_CONNECTED: |
| 237 | notificationMgr.showDataRoamingNotification(msg.arg1, true); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 238 | break; |
| 239 | |
| 240 | case EVENT_DATA_ROAMING_OK: |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 241 | notificationMgr.hideDataRoamingNotification(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 242 | break; |
| 243 | |
| 244 | case MMI_COMPLETE: |
| 245 | onMMIComplete((AsyncResult) msg.obj); |
| 246 | break; |
| 247 | |
| 248 | case MMI_CANCEL: |
Stuart Scott | dcf40a9 | 2014-12-09 10:45:01 -0800 | [diff] [blame] | 249 | PhoneUtils.cancelMmiCode(mCM.getFgPhone()); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 250 | break; |
| 251 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 252 | case EVENT_SIM_STATE_CHANGED: |
| 253 | // Marks the event where the SIM goes into ready state. |
| 254 | // Right now, this is only used for the PUK-unlocking |
| 255 | // process. |
Amit Mahajan | c08787c | 2019-03-26 16:11:55 -0700 | [diff] [blame] | 256 | if (msg.obj.equals(IccCardConstants.INTENT_VALUE_ICC_READY) |
| 257 | || msg.obj.equals(IccCardConstants.INTENT_VALUE_ICC_LOADED)) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 258 | // when the right event is triggered and there |
| 259 | // are UI objects in the foreground, we close |
| 260 | // them to display the lock panel. |
| 261 | if (mPUKEntryActivity != null) { |
| 262 | mPUKEntryActivity.finish(); |
| 263 | mPUKEntryActivity = null; |
| 264 | } |
| 265 | if (mPUKEntryProgressDialog != null) { |
| 266 | mPUKEntryProgressDialog.dismiss(); |
| 267 | mPUKEntryProgressDialog = null; |
| 268 | } |
| 269 | } |
| 270 | break; |
| 271 | |
| 272 | case EVENT_UNSOL_CDMA_INFO_RECORD: |
| 273 | //TODO: handle message here; |
| 274 | break; |
Brad Ebinger | 3fa4346 | 2016-04-12 16:06:48 -0700 | [diff] [blame] | 275 | case EVENT_RESTART_SIP: |
| 276 | // This should only run if the Phone process crashed and was restarted. We do |
| 277 | // not want this running if the device is still in the FBE encrypted state. |
Brad Ebinger | 2862612 | 2017-08-10 14:13:35 -0700 | [diff] [blame] | 278 | // This is the same procedure that is triggered in the SipIncomingCallReceiver |
Brad Ebinger | 3fa4346 | 2016-04-12 16:06:48 -0700 | [diff] [blame] | 279 | // upon BOOT_COMPLETED. |
Meng Wang | c04cd2d | 2019-10-04 12:00:06 -0700 | [diff] [blame] | 280 | UserManager userManager = |
| 281 | (UserManager) sMe.getSystemService(Context.USER_SERVICE); |
Brad Ebinger | 3fa4346 | 2016-04-12 16:06:48 -0700 | [diff] [blame] | 282 | if (userManager != null && userManager.isUserUnlocked()) { |
| 283 | SipUtil.startSipService(); |
| 284 | } |
| 285 | break; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 286 | case EVENT_DATA_ROAMING_SETTINGS_CHANGED: |
| 287 | case EVENT_MOBILE_DATA_SETTINGS_CHANGED: |
| 288 | updateDataRoamingStatus(); |
| 289 | break; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 290 | } |
| 291 | } |
| 292 | }; |
| 293 | |
| 294 | public PhoneGlobals(Context context) { |
| 295 | super(context); |
| 296 | sMe = this; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 297 | mSettingsObserver = new SettingsObserver(context, mHandler); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | public void onCreate() { |
| 301 | if (VDBG) Log.v(LOG_TAG, "onCreate()..."); |
| 302 | |
| 303 | ContentResolver resolver = getContentResolver(); |
| 304 | |
| 305 | // Cache the "voice capable" flag. |
| 306 | // This flag currently comes from a resource (which is |
| 307 | // overrideable on a per-product basis): |
| 308 | sVoiceCapable = |
| 309 | getResources().getBoolean(com.android.internal.R.bool.config_voice_capable); |
| 310 | // ...but this might eventually become a PackageManager "system |
| 311 | // feature" instead, in which case we'd do something like: |
| 312 | // sVoiceCapable = |
| 313 | // getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_VOICE_CALLS); |
| 314 | |
Stuart Scott | dcf40a9 | 2014-12-09 10:45:01 -0800 | [diff] [blame] | 315 | if (mCM == null) { |
Nathan Harold | f9df6ea | 2019-03-08 11:54:22 -0800 | [diff] [blame] | 316 | // Initialize AnomalyReporter early so that it can be used |
| 317 | AnomalyReporter.initialize(this); |
Nathan Harold | 0db5c5e | 2019-01-22 20:18:56 -0800 | [diff] [blame] | 318 | |
Youming Ye | 47a6adc | 2018-11-19 15:33:36 -0800 | [diff] [blame] | 319 | // Inject telephony component factory if configured using other jars. |
| 320 | XmlResourceParser parser = getResources().getXml(R.xml.telephony_injection); |
| 321 | TelephonyComponentFactory.getInstance().injectTheComponentFactory(parser); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 322 | // Initialize the telephony framework |
| 323 | PhoneFactory.makeDefaultPhones(this); |
| 324 | |
Brad Ebinger | 05f52c2 | 2019-12-05 13:03:21 -0800 | [diff] [blame] | 325 | // Only bring up ImsResolver if the device supports having an IMS stack. |
| 326 | if (getPackageManager().hasSystemFeature( |
| 327 | PackageManager.FEATURE_TELEPHONY_IMS)) { |
| 328 | // Get the package name of the default IMS implementation. |
| 329 | String defaultImsMmtelPackage = getResources().getString( |
| 330 | R.string.config_ims_mmtel_package); |
| 331 | String defaultImsRcsPackage = getResources().getString( |
| 332 | R.string.config_ims_rcs_package); |
| 333 | mImsResolver = new ImsResolver(this, defaultImsMmtelPackage, |
| 334 | defaultImsRcsPackage, PhoneFactory.getPhones().length); |
| 335 | mImsResolver.initialize(); |
| 336 | } |
| 337 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 338 | // Start TelephonyDebugService After the default phone is created. |
| 339 | Intent intent = new Intent(this, TelephonyDebugService.class); |
| 340 | startService(intent); |
| 341 | |
| 342 | mCM = CallManager.getInstance(); |
Stuart Scott | dcf40a9 | 2014-12-09 10:45:01 -0800 | [diff] [blame] | 343 | for (Phone phone : PhoneFactory.getPhones()) { |
| 344 | mCM.registerPhone(phone); |
Stuart Scott | dcf40a9 | 2014-12-09 10:45:01 -0800 | [diff] [blame] | 345 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 346 | |
| 347 | // Create the NotificationMgr singleton, which is used to display |
| 348 | // status bar icons and control other status bar behavior. |
| 349 | notificationMgr = NotificationMgr.init(this); |
| 350 | |
Brad Ebinger | 3fa4346 | 2016-04-12 16:06:48 -0700 | [diff] [blame] | 351 | // If PhoneGlobals has crashed and is being restarted, then restart. |
| 352 | mHandler.sendEmptyMessage(EVENT_RESTART_SIP); |
| 353 | |
Anthony Lee | 03ebdfc | 2015-07-27 08:12:02 -0700 | [diff] [blame] | 354 | // Create an instance of CdmaPhoneCallState and initialize it to IDLE |
| 355 | cdmaPhoneCallState = new CdmaPhoneCallState(); |
| 356 | cdmaPhoneCallState.CdmaPhoneCallStateInit(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 357 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 358 | // before registering for phone state changes |
| 359 | mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); |
| 360 | mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, LOG_TAG); |
| 361 | // lock used to keep the processor awake, when we don't care for the display. |
| 362 | mPartialWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK |
| 363 | | PowerManager.ON_AFTER_RELEASE, LOG_TAG); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 364 | |
| 365 | mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); |
| 366 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 367 | // Create the CallerInfoCache singleton, which remembers custom ring tone and |
| 368 | // send-to-voicemail settings. |
| 369 | // |
| 370 | // The asynchronous caching will start just after this call. |
| 371 | callerInfoCache = CallerInfoCache.init(this); |
| 372 | |
Nazanin Bakhshi | 2f2cc69 | 2018-12-11 15:15:39 -0800 | [diff] [blame] | 373 | phoneMgr = PhoneInterfaceManager.init(this); |
Santos Cordon | 406c034 | 2013-08-28 00:07:47 -0700 | [diff] [blame] | 374 | |
James.cf Lin | af3183c | 2019-10-24 00:59:00 +0800 | [diff] [blame] | 375 | imsRcsController = ImsRcsController.init(this); |
| 376 | |
James.cf Lin | c9f35a4 | 2020-01-15 02:35:22 +0800 | [diff] [blame^] | 377 | if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS)) { |
| 378 | mTelephonyRcsService = new TelephonyRcsService(this); |
| 379 | imsRcsController.setRcsService(mTelephonyRcsService); |
| 380 | } |
| 381 | |
Jonathan Basseri | 6465afd | 2015-02-25 13:05:57 -0800 | [diff] [blame] | 382 | configLoader = CarrierConfigLoader.init(this); |
| 383 | |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 384 | // Create the CallNotifier singleton, which handles |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 385 | // asynchronous events from the telephony layer (like |
| 386 | // launching the incoming-call UI when an incoming call comes |
| 387 | // in.) |
Brad Ebinger | a9c6b6d | 2016-01-07 17:24:16 -0800 | [diff] [blame] | 388 | notifier = CallNotifier.init(this); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 389 | |
Stuart Scott | dcf40a9 | 2014-12-09 10:45:01 -0800 | [diff] [blame] | 390 | PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 391 | |
| 392 | // register for MMI/USSD |
| 393 | mCM.registerForMmiComplete(mHandler, MMI_COMPLETE, null); |
| 394 | |
Qiong Liu | cc3fe81 | 2019-09-23 15:25:44 +0800 | [diff] [blame] | 395 | // Initialize cell status using current airplane mode. |
| 396 | handleAirplaneModeChange(this, Settings.Global.getInt(getContentResolver(), |
| 397 | Settings.Global.AIRPLANE_MODE_ON, AIRPLANE_OFF)); |
| 398 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 399 | // Register for misc other intent broadcasts. |
| 400 | IntentFilter intentFilter = |
| 401 | new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 402 | intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
| 403 | intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED); |
| 404 | intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
| 405 | intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 406 | intentFilter.addAction(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED); |
| 407 | intentFilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 408 | registerReceiver(mReceiver, intentFilter); |
| 409 | |
Brad Ebinger | 533c6c1 | 2017-08-02 11:38:48 -0700 | [diff] [blame] | 410 | IntentFilter sipIntentFilter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED); |
Brad Ebinger | 533c6c1 | 2017-08-02 11:38:48 -0700 | [diff] [blame] | 411 | sipIntentFilter.addAction(SipManager.ACTION_SIP_SERVICE_UP); |
| 412 | sipIntentFilter.addAction(SipManager.ACTION_SIP_CALL_OPTION_CHANGED); |
| 413 | sipIntentFilter.addAction(SipManager.ACTION_SIP_REMOVE_PHONE); |
Brad Ebinger | 2862612 | 2017-08-10 14:13:35 -0700 | [diff] [blame] | 414 | registerReceiver(mSipReceiver, sipIntentFilter); |
Brad Ebinger | 533c6c1 | 2017-08-02 11:38:48 -0700 | [diff] [blame] | 415 | |
Ta-wei Yen | f0a71bc | 2017-05-17 12:28:28 -0700 | [diff] [blame] | 416 | mCarrierVvmPackageInstalledReceiver.register(this); |
| 417 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 418 | //set the default values for the preferences in the phone. |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 419 | PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 420 | } |
| 421 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 422 | // XXX pre-load the SimProvider so that it's ready |
| 423 | resolver.getType(Uri.parse("content://icc/adn")); |
| 424 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 425 | // TODO: Register for Cdma Information Records |
| 426 | // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null); |
| 427 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 428 | // Read HAC settings and configure audio hardware |
| 429 | if (getResources().getBoolean(R.bool.hac_enabled)) { |
Stuart Scott | dcf40a9 | 2014-12-09 10:45:01 -0800 | [diff] [blame] | 430 | int hac = android.provider.Settings.System.getInt( |
| 431 | getContentResolver(), |
| 432 | android.provider.Settings.System.HEARING_AID, |
| 433 | 0); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 434 | AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); |
Jordan Liu | f71aeef | 2019-08-21 11:46:09 -0700 | [diff] [blame] | 435 | audioManager.setParameters( |
| 436 | SettingsConstants.HAC_KEY + "=" + (hac == SettingsConstants.HAC_ENABLED |
| 437 | ? SettingsConstants.HAC_VAL_ON : SettingsConstants.HAC_VAL_OFF)); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 438 | } |
Santos Cordon | ff506f5 | 2013-11-21 19:13:19 -0800 | [diff] [blame] | 439 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 440 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 441 | /** |
| 442 | * Returns the singleton instance of the PhoneApp. |
| 443 | */ |
Sailesh Nepal | 1eaf22b | 2014-02-22 17:00:49 -0800 | [diff] [blame] | 444 | public static PhoneGlobals getInstance() { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 445 | if (sMe == null) { |
| 446 | throw new IllegalStateException("No PhoneGlobals here!"); |
| 447 | } |
| 448 | return sMe; |
| 449 | } |
| 450 | |
| 451 | /** |
Stuart Scott | dcf40a9 | 2014-12-09 10:45:01 -0800 | [diff] [blame] | 452 | * Returns the default phone. |
| 453 | * |
Andrew Lee | 385019f | 2014-11-24 14:19:50 -0800 | [diff] [blame] | 454 | * WARNING: This method should be used carefully, now that there may be multiple phones. |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 455 | */ |
Andrew Lee | 83383e4 | 2014-10-31 12:42:28 -0700 | [diff] [blame] | 456 | public static Phone getPhone() { |
Stuart Scott | dcf40a9 | 2014-12-09 10:45:01 -0800 | [diff] [blame] | 457 | return PhoneFactory.getDefaultPhone(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 458 | } |
| 459 | |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 460 | public static Phone getPhone(int subId) { |
| 461 | return PhoneFactory.getPhone(SubscriptionManager.getPhoneId(subId)); |
Andrew Lee | 385019f | 2014-11-24 14:19:50 -0800 | [diff] [blame] | 462 | } |
| 463 | |
Brad Ebinger | 05f52c2 | 2019-12-05 13:03:21 -0800 | [diff] [blame] | 464 | public ImsResolver getImsResolver() { |
| 465 | return mImsResolver; |
| 466 | } |
| 467 | |
Santos Cordon | de10b75 | 2013-09-19 04:11:33 -0700 | [diff] [blame] | 468 | /* package */ CallManager getCallManager() { |
| 469 | return mCM; |
| 470 | } |
| 471 | |
Chris Manton | 4e9fa91 | 2015-06-19 11:26:57 -0700 | [diff] [blame] | 472 | public PersistableBundle getCarrierConfig() { |
Shishir Agrawal | d3480e0 | 2016-01-25 13:05:49 -0800 | [diff] [blame] | 473 | return getCarrierConfigForSubId(SubscriptionManager.getDefaultSubscriptionId()); |
Jonathan Basseri | 89b0ab4 | 2015-05-01 10:52:40 -0700 | [diff] [blame] | 474 | } |
| 475 | |
Chris Manton | 4e9fa91 | 2015-06-19 11:26:57 -0700 | [diff] [blame] | 476 | public PersistableBundle getCarrierConfigForSubId(int subId) { |
Philip P. Moltmann | 9797cbb | 2020-01-07 13:45:00 -0800 | [diff] [blame] | 477 | return configLoader.getConfigForSubIdWithFeature(subId, getOpPackageName(), null); |
Junda Liu | 605148f | 2015-04-28 15:23:40 -0700 | [diff] [blame] | 478 | } |
| 479 | |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 480 | private void registerSettingsObserver() { |
| 481 | mSettingsObserver.unobserve(); |
| 482 | String dataRoamingSetting = Settings.Global.DATA_ROAMING; |
| 483 | String mobileDataSetting = Settings.Global.MOBILE_DATA; |
| 484 | if (TelephonyManager.getDefault().getSimCount() > 1) { |
| 485 | int subId = mDefaultDataSubId; |
| 486 | if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { |
| 487 | dataRoamingSetting += subId; |
| 488 | mobileDataSetting += subId; |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | // Listen for user data roaming setting changed event |
| 493 | mSettingsObserver.observe(Settings.Global.getUriFor(dataRoamingSetting), |
| 494 | EVENT_DATA_ROAMING_SETTINGS_CHANGED); |
| 495 | |
| 496 | // Listen for mobile data setting changed event |
| 497 | mSettingsObserver.observe(Settings.Global.getUriFor(mobileDataSetting), |
| 498 | EVENT_MOBILE_DATA_SETTINGS_CHANGED); |
| 499 | } |
| 500 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 501 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 502 | * Sets the activity responsible for un-PUK-blocking the device |
| 503 | * so that we may close it when we receive a positive result. |
| 504 | * mPUKEntryActivity is also used to indicate to the device that |
| 505 | * we are trying to un-PUK-lock the phone. In other words, iff |
| 506 | * it is NOT null, then we are trying to unlock and waiting for |
| 507 | * the SIM to move to READY state. |
| 508 | * |
| 509 | * @param activity is the activity to close when PUK has |
| 510 | * finished unlocking. Can be set to null to indicate the unlock |
| 511 | * or SIM READYing process is over. |
| 512 | */ |
| 513 | void setPukEntryActivity(Activity activity) { |
| 514 | mPUKEntryActivity = activity; |
| 515 | } |
| 516 | |
| 517 | Activity getPUKEntryActivity() { |
| 518 | return mPUKEntryActivity; |
| 519 | } |
| 520 | |
| 521 | /** |
| 522 | * Sets the dialog responsible for notifying the user of un-PUK- |
| 523 | * blocking - SIM READYing progress, so that we may dismiss it |
| 524 | * when we receive a positive result. |
| 525 | * |
| 526 | * @param dialog indicates the progress dialog informing the user |
| 527 | * of the state of the device. Dismissed upon completion of |
| 528 | * READYing process |
| 529 | */ |
| 530 | void setPukEntryProgressDialog(ProgressDialog dialog) { |
| 531 | mPUKEntryProgressDialog = dialog; |
| 532 | } |
| 533 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 534 | KeyguardManager getKeyguardManager() { |
| 535 | return mKeyguardManager; |
| 536 | } |
| 537 | |
| 538 | private void onMMIComplete(AsyncResult r) { |
| 539 | if (VDBG) Log.d(LOG_TAG, "onMMIComplete()..."); |
| 540 | MmiCode mmiCode = (MmiCode) r.result; |
Stuart Scott | dcf40a9 | 2014-12-09 10:45:01 -0800 | [diff] [blame] | 541 | PhoneUtils.displayMMIComplete(mmiCode.getPhone(), getInstance(), mmiCode, null, null); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 542 | } |
| 543 | |
fionaxu | 8012697 | 2017-02-01 17:01:26 -0800 | [diff] [blame] | 544 | private void initForNewRadioTechnology() { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 545 | if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology..."); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 546 | notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 547 | } |
| 548 | |
Chris Manton | a09f363 | 2016-02-09 14:48:42 -0800 | [diff] [blame] | 549 | private void handleAirplaneModeChange(Context context, int newMode) { |
| 550 | int cellState = Settings.Global.getInt(context.getContentResolver(), |
| 551 | Settings.Global.CELL_ON, PhoneConstants.CELL_ON_FLAG); |
| 552 | boolean isAirplaneNewlyOn = (newMode == 1); |
| 553 | switch (cellState) { |
| 554 | case PhoneConstants.CELL_OFF_FLAG: |
| 555 | // Airplane mode does not affect the cell radio if user |
| 556 | // has turned it off. |
| 557 | break; |
| 558 | case PhoneConstants.CELL_ON_FLAG: |
| 559 | maybeTurnCellOff(context, isAirplaneNewlyOn); |
| 560 | break; |
| 561 | case PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG: |
| 562 | maybeTurnCellOn(context, isAirplaneNewlyOn); |
| 563 | break; |
| 564 | } |
Hall Liu | 7f56e1a | 2019-07-10 14:41:14 -0700 | [diff] [blame] | 565 | for (Phone phone : PhoneFactory.getPhones()) { |
| 566 | phone.getServiceStateTracker().onAirplaneModeChanged(isAirplaneNewlyOn); |
| 567 | } |
Chris Manton | a09f363 | 2016-02-09 14:48:42 -0800 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | /* |
| 571 | * Returns true if the radio must be turned off when entering airplane mode. |
| 572 | */ |
| 573 | private boolean isCellOffInAirplaneMode(Context context) { |
| 574 | String airplaneModeRadios = Settings.Global.getString(context.getContentResolver(), |
| 575 | Settings.Global.AIRPLANE_MODE_RADIOS); |
| 576 | return airplaneModeRadios == null |
| 577 | || airplaneModeRadios.contains(Settings.Global.RADIO_CELL); |
| 578 | } |
| 579 | |
| 580 | private void setRadioPowerOff(Context context) { |
| 581 | Log.i(LOG_TAG, "Turning radio off - airplane"); |
| 582 | Settings.Global.putInt(context.getContentResolver(), Settings.Global.CELL_ON, |
Eric Erfanian | 945409f | 2018-02-21 19:26:15 +0000 | [diff] [blame] | 583 | PhoneConstants.CELL_OFF_DUE_TO_AIRPLANE_MODE_FLAG); |
Meng Wang | 6130762 | 2019-10-23 14:08:43 -0700 | [diff] [blame] | 584 | TelephonyProperties.airplane_mode_on(true); // true means int value 1 |
Chris Manton | a09f363 | 2016-02-09 14:48:42 -0800 | [diff] [blame] | 585 | Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT, 0); |
| 586 | PhoneUtils.setRadioPower(false); |
| 587 | } |
| 588 | |
| 589 | private void setRadioPowerOn(Context context) { |
| 590 | Log.i(LOG_TAG, "Turning radio on - airplane"); |
| 591 | Settings.Global.putInt(context.getContentResolver(), Settings.Global.CELL_ON, |
| 592 | PhoneConstants.CELL_ON_FLAG); |
| 593 | Settings.Global.putInt(getContentResolver(), Settings.Global.ENABLE_CELLULAR_ON_BOOT, |
| 594 | 1); |
Meng Wang | 6130762 | 2019-10-23 14:08:43 -0700 | [diff] [blame] | 595 | TelephonyProperties.airplane_mode_on(false); // false means int value 0 |
Chris Manton | a09f363 | 2016-02-09 14:48:42 -0800 | [diff] [blame] | 596 | PhoneUtils.setRadioPower(true); |
| 597 | } |
| 598 | |
| 599 | private void maybeTurnCellOff(Context context, boolean isAirplaneNewlyOn) { |
| 600 | if (isAirplaneNewlyOn) { |
Santos Cordon | e18902f | 2016-03-22 17:16:04 -0700 | [diff] [blame] | 601 | // If we are trying to turn off the radio, make sure there are no active |
| 602 | // emergency calls. If there are, switch airplane mode back to off. |
Tyler Gunn | 900d8fd | 2018-09-21 09:22:12 -0700 | [diff] [blame] | 603 | TelecomManager tm = (TelecomManager) context.getSystemService(TELECOM_SERVICE); |
| 604 | |
| 605 | if (tm != null && tm.isInEmergencyCall()) { |
Santos Cordon | e18902f | 2016-03-22 17:16:04 -0700 | [diff] [blame] | 606 | // Switch airplane mode back to off. |
Jordan Liu | 0e819b1 | 2019-08-28 15:33:05 -0700 | [diff] [blame] | 607 | ConnectivityManager cm = |
| 608 | (ConnectivityManager) context.getSystemService(CONNECTIVITY_SERVICE); |
| 609 | cm.setAirplaneMode(false); |
Santos Cordon | e18902f | 2016-03-22 17:16:04 -0700 | [diff] [blame] | 610 | Toast.makeText(this, R.string.radio_off_during_emergency_call, Toast.LENGTH_LONG) |
| 611 | .show(); |
| 612 | Log.i(LOG_TAG, "Ignoring airplane mode: emergency call. Turning airplane off"); |
Chris Manton | a09f363 | 2016-02-09 14:48:42 -0800 | [diff] [blame] | 613 | } else if (isCellOffInAirplaneMode(context)) { |
| 614 | setRadioPowerOff(context); |
Santos Cordon | e18902f | 2016-03-22 17:16:04 -0700 | [diff] [blame] | 615 | } else { |
Chris Manton | a09f363 | 2016-02-09 14:48:42 -0800 | [diff] [blame] | 616 | Log.i(LOG_TAG, "Ignoring airplane mode: settings prevent cell radio power off"); |
Santos Cordon | e18902f | 2016-03-22 17:16:04 -0700 | [diff] [blame] | 617 | } |
Chris Manton | a09f363 | 2016-02-09 14:48:42 -0800 | [diff] [blame] | 618 | } |
| 619 | } |
| 620 | |
| 621 | private void maybeTurnCellOn(Context context, boolean isAirplaneNewlyOn) { |
| 622 | if (!isAirplaneNewlyOn) { |
| 623 | setRadioPowerOn(context); |
Santos Cordon | e18902f | 2016-03-22 17:16:04 -0700 | [diff] [blame] | 624 | } |
| 625 | } |
| 626 | |
Santos Cordon | 593ab38 | 2013-08-06 21:58:23 -0700 | [diff] [blame] | 627 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 628 | * Receiver for misc intent broadcasts the Phone app cares about. |
| 629 | */ |
| 630 | private class PhoneAppBroadcastReceiver extends BroadcastReceiver { |
| 631 | @Override |
| 632 | public void onReceive(Context context, Intent intent) { |
| 633 | String action = intent.getAction(); |
| 634 | if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) { |
Santos Cordon | e18902f | 2016-03-22 17:16:04 -0700 | [diff] [blame] | 635 | int airplaneMode = Settings.Global.getInt(getContentResolver(), |
| 636 | Settings.Global.AIRPLANE_MODE_ON, AIRPLANE_OFF); |
| 637 | // Treat any non-OFF values as ON. |
| 638 | if (airplaneMode != AIRPLANE_OFF) { |
| 639 | airplaneMode = AIRPLANE_ON; |
| 640 | } |
Chris Manton | a09f363 | 2016-02-09 14:48:42 -0800 | [diff] [blame] | 641 | handleAirplaneModeChange(context, airplaneMode); |
Amit Mahajan | f5d92c8 | 2018-11-02 17:44:40 -0700 | [diff] [blame] | 642 | } else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { |
| 643 | // re-register as it may be a new IccCard |
| 644 | int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY, |
| 645 | SubscriptionManager.INVALID_PHONE_INDEX); |
| 646 | if (SubscriptionManager.isValidPhoneId(phoneId)) { |
| 647 | PhoneUtils.unregisterIccStatus(mHandler, phoneId); |
| 648 | PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED, phoneId); |
| 649 | } |
| 650 | if (mPUKEntryActivity != null) { |
| 651 | // if an attempt to un-PUK-lock the device was made, while we're |
| 652 | // receiving this state change notification, notify the handler. |
| 653 | // NOTE: This is ONLY triggered if an attempt to un-PUK-lock has |
| 654 | // been attempted. |
| 655 | mHandler.sendMessage(mHandler.obtainMessage(EVENT_SIM_STATE_CHANGED, |
| 656 | intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE))); |
| 657 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 658 | } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) { |
| 659 | String newPhone = intent.getStringExtra(PhoneConstants.PHONE_NAME_KEY); |
fionaxu | 8012697 | 2017-02-01 17:01:26 -0800 | [diff] [blame] | 660 | Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active."); |
| 661 | initForNewRadioTechnology(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 662 | } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) { |
| 663 | handleServiceStateChanged(intent); |
| 664 | } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) { |
Sandeep Kunta | de73a6a | 2014-10-15 18:45:56 +0530 | [diff] [blame] | 665 | int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY, 0); |
Srikanth Chintala | 079912a | 2016-03-03 16:35:01 +0530 | [diff] [blame] | 666 | phoneInEcm = PhoneFactory.getPhone(phoneId); |
Sandeep Kunta | de73a6a | 2014-10-15 18:45:56 +0530 | [diff] [blame] | 667 | Log.d(LOG_TAG, "Emergency Callback Mode. phoneId:" + phoneId); |
| 668 | if (phoneInEcm != null) { |
| 669 | if (TelephonyCapabilities.supportsEcm(phoneInEcm)) { |
| 670 | Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp."); |
| 671 | // Start Emergency Callback Mode service |
| 672 | if (intent.getBooleanExtra("phoneinECMState", false)) { |
| 673 | context.startService(new Intent(context, |
| 674 | EmergencyCallbackModeService.class)); |
| 675 | } else { |
| 676 | phoneInEcm = null; |
| 677 | } |
| 678 | } else { |
| 679 | // It doesn't make sense to get ACTION_EMERGENCY_CALLBACK_MODE_CHANGED |
| 680 | // on a device that doesn't support ECM in the first place. |
| 681 | Log.e(LOG_TAG, "Got ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, but " |
| 682 | + "ECM isn't supported for phone: " + phoneInEcm.getPhoneName()); |
| 683 | phoneInEcm = null; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 684 | } |
| 685 | } else { |
Sandeep Kunta | de73a6a | 2014-10-15 18:45:56 +0530 | [diff] [blame] | 686 | Log.w(LOG_TAG, "phoneInEcm is null."); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 687 | } |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 688 | } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) { |
| 689 | // Roaming status could be overridden by carrier config, so we need to update it. |
| 690 | if (VDBG) Log.v(LOG_TAG, "carrier config changed."); |
| 691 | updateDataRoamingStatus(); |
chen xu | baf9fe5 | 2019-07-02 17:28:24 -0700 | [diff] [blame] | 692 | updateLimitedSimFunctionForDualSim(); |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 693 | } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) { |
| 694 | // We also need to pay attention when default data subscription changes. |
| 695 | if (VDBG) Log.v(LOG_TAG, "default data sub changed."); |
| 696 | mDefaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId(); |
| 697 | registerSettingsObserver(); |
| 698 | Phone phone = getPhone(mDefaultDataSubId); |
| 699 | if (phone != null) { |
| 700 | updateDataRoamingStatus(); |
| 701 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 702 | } |
| 703 | } |
| 704 | } |
| 705 | |
Brad Ebinger | 2862612 | 2017-08-10 14:13:35 -0700 | [diff] [blame] | 706 | private class SipReceiver extends BroadcastReceiver { |
| 707 | |
| 708 | @Override |
| 709 | public void onReceive(Context context, Intent intent) { |
| 710 | String action = intent.getAction(); |
| 711 | |
| 712 | SipAccountRegistry sipAccountRegistry = SipAccountRegistry.getInstance(); |
| 713 | if (action.equals(Intent.ACTION_BOOT_COMPLETED)) { |
| 714 | SipUtil.startSipService(); |
| 715 | } else if (action.equals(SipManager.ACTION_SIP_SERVICE_UP) |
| 716 | || action.equals(SipManager.ACTION_SIP_CALL_OPTION_CHANGED)) { |
| 717 | sipAccountRegistry.setup(context); |
| 718 | } else if (action.equals(SipManager.ACTION_SIP_REMOVE_PHONE)) { |
| 719 | if (DBG) { |
| 720 | Log.d(LOG_TAG, "SIP_REMOVE_PHONE " |
| 721 | + intent.getStringExtra(SipManager.EXTRA_LOCAL_URI)); |
| 722 | } |
| 723 | sipAccountRegistry.removeSipProfile(intent.getStringExtra( |
| 724 | SipManager.EXTRA_LOCAL_URI)); |
| 725 | } else { |
| 726 | if (DBG) Log.d(LOG_TAG, "onReceive, action not processed: " + action); |
| 727 | } |
| 728 | } |
| 729 | } |
| 730 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 731 | private void handleServiceStateChanged(Intent intent) { |
| 732 | /** |
| 733 | * This used to handle updating EriTextWidgetProvider this routine |
| 734 | * and and listening for ACTION_SERVICE_STATE_CHANGED intents could |
| 735 | * be removed. But leaving just in case it might be needed in the near |
| 736 | * future. |
| 737 | */ |
| 738 | |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 739 | if (VDBG) Log.v(LOG_TAG, "handleServiceStateChanged"); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 740 | // If service just returned, start sending out the queued messages |
Santos Cordon | c593d00 | 2015-06-03 15:41:15 -0700 | [diff] [blame] | 741 | Bundle extras = intent.getExtras(); |
| 742 | if (extras != null) { |
| 743 | ServiceState ss = ServiceState.newFromBundle(extras); |
| 744 | if (ss != null) { |
| 745 | int state = ss.getState(); |
Jayachandran C | 2ef9a48 | 2017-05-12 22:07:47 -0700 | [diff] [blame] | 746 | int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, |
| 747 | SubscriptionManager.INVALID_SUBSCRIPTION_ID); |
| 748 | notificationMgr.updateNetworkSelection(state, subId); |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 749 | |
| 750 | if (VDBG) { |
| 751 | Log.v(LOG_TAG, "subId=" + subId + ",mDefaultDataSubId=" |
| 752 | + mDefaultDataSubId + ",ss roaming=" + ss.getDataRoaming()); |
| 753 | } |
| 754 | if (subId == mDefaultDataSubId) { |
| 755 | updateDataRoamingStatus(); |
| 756 | } |
Santos Cordon | c593d00 | 2015-06-03 15:41:15 -0700 | [diff] [blame] | 757 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 758 | } |
| 759 | } |
| 760 | |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 761 | /** |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 762 | * @return whether or not we should show a notification when connecting to data roaming if the |
| 763 | * user has data roaming enabled |
| 764 | */ |
| 765 | private boolean shouldShowDataConnectedRoaming(int subId) { |
| 766 | PersistableBundle config = getCarrierConfigForSubId(subId); |
| 767 | return config.getBoolean(CarrierConfigManager |
| 768 | .KEY_SHOW_DATA_CONNECTED_ROAMING_NOTIFICATION_BOOL); |
| 769 | } |
| 770 | |
| 771 | /** |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 772 | * When roaming, if mobile data cannot be established due to data roaming not enabled, we need |
| 773 | * to notify the user so they can enable it through settings. Vise versa if the condition |
| 774 | * changes, we need to dismiss the notification. |
| 775 | */ |
| 776 | private void updateDataRoamingStatus() { |
| 777 | if (VDBG) Log.v(LOG_TAG, "updateDataRoamingStatus"); |
| 778 | Phone phone = getPhone(mDefaultDataSubId); |
| 779 | if (phone == null) { |
| 780 | Log.w(LOG_TAG, "Can't get phone with sub id = " + mDefaultDataSubId); |
| 781 | return; |
| 782 | } |
| 783 | |
| 784 | DataConnectionReasons reasons = new DataConnectionReasons(); |
Jack Yu | 311536f | 2018-11-26 11:20:48 -0800 | [diff] [blame] | 785 | boolean dataAllowed = phone.isDataAllowed(ApnSetting.TYPE_DEFAULT, reasons); |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 786 | mDataRoamingNotifLog.log("dataAllowed=" + dataAllowed + ", reasons=" + reasons); |
| 787 | if (VDBG) Log.v(LOG_TAG, "dataAllowed=" + dataAllowed + ", reasons=" + reasons); |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 788 | if (!dataAllowed && reasons.containsOnly(DataDisallowedReasonType.ROAMING_DISABLED)) { |
| 789 | // No need to show it again if we never cancelled it explicitly. |
| 790 | if (mPrevRoamingNotification == ROAMING_NOTIFICATION_DISCONNECTED) return; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 791 | // If the only reason of no data is data roaming disabled, then we notify the user |
| 792 | // so the user can turn on data roaming. |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 793 | mPrevRoamingNotification = ROAMING_NOTIFICATION_DISCONNECTED; |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 794 | Log.d(LOG_TAG, "Show roaming disconnected notification"); |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 795 | mDataRoamingNotifLog.log("Show roaming off."); |
Pengquan Meng | 8783d93 | 2017-10-16 14:57:40 -0700 | [diff] [blame] | 796 | Message msg = mHandler.obtainMessage(EVENT_DATA_ROAMING_DISCONNECTED); |
| 797 | msg.arg1 = mDefaultDataSubId; |
| 798 | msg.sendToTarget(); |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 799 | } else if (dataAllowed && dataIsNowRoaming(mDefaultDataSubId) |
| 800 | && shouldShowDataConnectedRoaming(mDefaultDataSubId)) { |
| 801 | // No need to show it again if we never cancelled it explicitly, or carrier config |
| 802 | // indicates this is not needed. |
| 803 | if (mPrevRoamingNotification == ROAMING_NOTIFICATION_CONNECTED) return; |
| 804 | mPrevRoamingNotification = ROAMING_NOTIFICATION_CONNECTED; |
| 805 | Log.d(LOG_TAG, "Show roaming connected notification"); |
| 806 | mDataRoamingNotifLog.log("Show roaming on."); |
| 807 | Message msg = mHandler.obtainMessage(EVENT_DATA_ROAMING_CONNECTED); |
| 808 | msg.arg1 = mDefaultDataSubId; |
| 809 | msg.sendToTarget(); |
| 810 | } else if (mPrevRoamingNotification != ROAMING_NOTIFICATION_NO_NOTIFICATION) { |
| 811 | // Otherwise we either 1) we are not roaming or 2) roaming is off but ROAMING_DISABLED |
| 812 | // is not the only data disable reason. In this case we dismiss the notification we |
| 813 | // showed earlier. |
| 814 | mPrevRoamingNotification = ROAMING_NOTIFICATION_NO_NOTIFICATION; |
| 815 | Log.d(LOG_TAG, "Dismiss roaming notification"); |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 816 | mDataRoamingNotifLog.log("Hide. data allowed=" + dataAllowed + ", reasons=" + reasons); |
| 817 | mHandler.sendEmptyMessage(EVENT_DATA_ROAMING_OK); |
| 818 | } |
| 819 | } |
| 820 | |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 821 | /** |
| 822 | * |
| 823 | * @param subId to check roaming on |
| 824 | * @return whether we have transitioned to dataRoaming |
| 825 | */ |
| 826 | private boolean dataIsNowRoaming(int subId) { |
| 827 | return getPhone(subId).getServiceState().getDataRoaming(); |
| 828 | } |
| 829 | |
chen xu | baf9fe5 | 2019-07-02 17:28:24 -0700 | [diff] [blame] | 830 | private void updateLimitedSimFunctionForDualSim() { |
| 831 | if (DBG) Log.d(LOG_TAG, "updateLimitedSimFunctionForDualSim"); |
| 832 | // check conditions to display limited SIM function notification under dual SIM |
| 833 | SubscriptionManager subMgr = (SubscriptionManager) getSystemService( |
| 834 | Context.TELEPHONY_SUBSCRIPTION_SERVICE); |
| 835 | List<SubscriptionInfo> subList = subMgr.getActiveSubscriptionInfoList(false); |
| 836 | if (subList != null && subList.size() > 1) { |
| 837 | CarrierConfigManager configMgr = (CarrierConfigManager) |
| 838 | getSystemService(Context.CARRIER_CONFIG_SERVICE); |
| 839 | for (SubscriptionInfo info : subList) { |
| 840 | PersistableBundle b = configMgr.getConfigForSubId(info.getSubscriptionId()); |
| 841 | if (b != null) { |
| 842 | if (b.getBoolean(CarrierConfigManager |
| 843 | .KEY_LIMITED_SIM_FUNCTION_NOTIFICATION_FOR_DSDS_BOOL)) { |
| 844 | notificationMgr.showLimitedSimFunctionWarningNotification( |
| 845 | info.getSubscriptionId(), |
| 846 | info.getDisplayName().toString()); |
| 847 | } else { |
| 848 | notificationMgr.dismissLimitedSimFunctionWarningNotification( |
| 849 | info.getSubscriptionId()); |
| 850 | } |
| 851 | } |
| 852 | } |
| 853 | } else { |
| 854 | // cancel notifications for all subs |
| 855 | notificationMgr.dismissLimitedSimFunctionWarningNotification( |
| 856 | SubscriptionManager.INVALID_SUBSCRIPTION_ID); |
| 857 | } |
| 858 | notificationMgr.dismissLimitedSimFunctionWarningNotificationForInactiveSubs(); |
| 859 | |
| 860 | } |
| 861 | |
Sandeep Kunta | de73a6a | 2014-10-15 18:45:56 +0530 | [diff] [blame] | 862 | public Phone getPhoneInEcm() { |
| 863 | return phoneInEcm; |
| 864 | } |
| 865 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 866 | /** |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 867 | * Triggers a refresh of the message waiting (voicemail) indicator. |
| 868 | * |
| 869 | * @param subId the subscription id we should refresh the notification for. |
| 870 | */ |
| 871 | public void refreshMwiIndicator(int subId) { |
| 872 | notificationMgr.refreshMwi(subId); |
| 873 | } |
| 874 | |
| 875 | /** |
Pengquan Meng | dd9ac82 | 2018-09-20 15:25:35 -0700 | [diff] [blame] | 876 | * Called when the network selection on the subscription {@code subId} is changed by the user. |
| 877 | * |
| 878 | * @param subId the subscription id. |
| 879 | */ |
| 880 | public void onNetworkSelectionChanged(int subId) { |
| 881 | Phone phone = getPhone(subId); |
| 882 | if (phone != null) { |
| 883 | notificationMgr.updateNetworkSelection(phone.getServiceState().getState(), subId); |
| 884 | } else { |
| 885 | Log.w(LOG_TAG, "onNetworkSelectionChanged on null phone, subId: " + subId); |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | /** |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 890 | * Dump the state of the object, add calls to other objects as desired. |
| 891 | * |
| 892 | * @param fd File descriptor |
| 893 | * @param printWriter Print writer |
| 894 | * @param args Arguments |
| 895 | */ |
| 896 | public void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) { |
| 897 | IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " "); |
| 898 | pw.println("------- PhoneGlobals -------"); |
| 899 | pw.increaseIndent(); |
Jordan Liu | ff2ccd7 | 2019-07-23 15:54:41 -0700 | [diff] [blame] | 900 | pw.println("mPrevRoamingNotification=" + mPrevRoamingNotification); |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 901 | pw.println("mDefaultDataSubId=" + mDefaultDataSubId); |
| 902 | pw.println("mDataRoamingNotifLog:"); |
Keun young Park | debb853 | 2019-05-30 16:35:27 -0700 | [diff] [blame] | 903 | pw.println("isSmsCapable=" + TelephonyManager.from(this).isSmsCapable()); |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 904 | pw.increaseIndent(); |
| 905 | mDataRoamingNotifLog.dump(fd, pw, args); |
| 906 | pw.decreaseIndent(); |
Brad Ebinger | 05f52c2 | 2019-12-05 13:03:21 -0800 | [diff] [blame] | 907 | pw.println("ImsResolver:"); |
| 908 | pw.increaseIndent(); |
| 909 | try { |
| 910 | if (mImsResolver != null) mImsResolver.dump(fd, pw, args); |
| 911 | } catch (Exception e) { |
| 912 | e.printStackTrace(); |
| 913 | } |
| 914 | pw.decreaseIndent(); |
Jack Yu | 1a2fc35 | 2017-07-14 17:14:37 -0700 | [diff] [blame] | 915 | pw.decreaseIndent(); |
| 916 | pw.println("------- End PhoneGlobals -------"); |
| 917 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 918 | } |