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 | |
| 19 | import android.app.Notification; |
| 20 | import android.app.NotificationManager; |
| 21 | import android.app.PendingIntent; |
| 22 | import android.app.StatusBarManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 23 | import android.content.ComponentName; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 24 | import android.content.Context; |
| 25 | import android.content.Intent; |
| 26 | import android.content.SharedPreferences; |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 27 | import android.content.pm.UserInfo; |
Nancy Chen | b4a9270 | 2014-12-04 15:57:29 -0800 | [diff] [blame] | 28 | import android.content.res.Resources; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 29 | import android.net.Uri; |
Jonathan Basseri | c31f1f3 | 2015-05-12 10:13:03 -0700 | [diff] [blame] | 30 | import android.os.PersistableBundle; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 31 | import android.os.SystemProperties; |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 32 | import android.os.UserHandle; |
| 33 | import android.os.UserManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 34 | import android.preference.PreferenceManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 35 | import android.provider.ContactsContract.PhoneLookup; |
Tyler Gunn | 4d45d1c | 2014-09-12 22:17:53 -0700 | [diff] [blame] | 36 | import android.telecom.PhoneAccount; |
Andrew Lee | d5165b0 | 2014-12-05 15:53:58 -0800 | [diff] [blame] | 37 | import android.telecom.PhoneAccountHandle; |
| 38 | import android.telecom.TelecomManager; |
Jonathan Basseri | 3649bdb | 2015-04-30 22:39:11 -0700 | [diff] [blame] | 39 | import android.telephony.CarrierConfigManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 40 | import android.telephony.PhoneNumberUtils; |
| 41 | import android.telephony.ServiceState; |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 42 | import android.telephony.SubscriptionInfo; |
Andrew Lee | a82b820 | 2014-11-21 16:18:28 -0800 | [diff] [blame] | 43 | import android.telephony.SubscriptionManager; |
Andrew Lee | d5165b0 | 2014-12-05 15:53:58 -0800 | [diff] [blame] | 44 | import android.telephony.TelephonyManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 45 | import android.text.TextUtils; |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 46 | import android.util.ArrayMap; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 47 | import android.util.Log; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 48 | import android.widget.Toast; |
| 49 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 50 | import com.android.internal.telephony.Phone; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 51 | import com.android.internal.telephony.TelephonyCapabilities; |
Andrew Lee | bf07f76 | 2015-04-07 19:05:50 -0700 | [diff] [blame] | 52 | import com.android.phone.settings.VoicemailSettingsActivity; |
Nancy Chen | 2cf7f29 | 2015-05-15 11:00:10 -0700 | [diff] [blame] | 53 | import com.android.phone.vvm.omtp.sync.VoicemailStatusQueryHelper; |
Andrew Lee | 8d66d81 | 2014-11-24 14:54:02 -0800 | [diff] [blame] | 54 | import com.android.phone.settings.VoicemailNotificationSettingsUtil; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 55 | |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 56 | import java.util.Iterator; |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 57 | import java.util.List; |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 58 | import java.util.Set; |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 59 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 60 | /** |
| 61 | * NotificationManager-related utility code for the Phone app. |
| 62 | * |
| 63 | * This is a singleton object which acts as the interface to the |
| 64 | * framework's NotificationManager, and is used to display status bar |
| 65 | * icons and control other status bar-related behavior. |
| 66 | * |
| 67 | * @see PhoneGlobals.notificationMgr |
| 68 | */ |
Chiao Cheng | 312b9c9 | 2013-09-16 15:40:53 -0700 | [diff] [blame] | 69 | public class NotificationMgr { |
Andrew Lee | a82b820 | 2014-11-21 16:18:28 -0800 | [diff] [blame] | 70 | private static final String LOG_TAG = NotificationMgr.class.getSimpleName(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 71 | private static final boolean DBG = |
| 72 | (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1); |
| 73 | // Do not check in with VDBG = true, since that may write PII to the system log. |
| 74 | private static final boolean VDBG = false; |
| 75 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 76 | // notification types |
Santos Cordon | f68db2e | 2014-07-02 14:40:44 -0700 | [diff] [blame] | 77 | static final int MMI_NOTIFICATION = 1; |
| 78 | static final int NETWORK_SELECTION_NOTIFICATION = 2; |
| 79 | static final int VOICEMAIL_NOTIFICATION = 3; |
| 80 | static final int CALL_FORWARD_NOTIFICATION = 4; |
| 81 | static final int DATA_DISCONNECTED_ROAMING_NOTIFICATION = 5; |
| 82 | static final int SELECTED_OPERATOR_FAIL_NOTIFICATION = 6; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 83 | |
| 84 | /** The singleton NotificationMgr instance. */ |
| 85 | private static NotificationMgr sInstance; |
| 86 | |
| 87 | private PhoneGlobals mApp; |
| 88 | private Phone mPhone; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 89 | |
| 90 | private Context mContext; |
| 91 | private NotificationManager mNotificationManager; |
Bryce Lee | 5dc9084 | 2015-08-11 07:57:14 -0700 | [diff] [blame] | 92 | private final ComponentName mNotificationComponent; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 93 | private StatusBarManager mStatusBarManager; |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 94 | private UserManager mUserManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 95 | private Toast mToast; |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 96 | private SubscriptionManager mSubscriptionManager; |
Andrew Lee | d5165b0 | 2014-12-05 15:53:58 -0800 | [diff] [blame] | 97 | private TelecomManager mTelecomManager; |
| 98 | private TelephonyManager mTelephonyManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 99 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 100 | // used to track the notification of selected network unavailable |
| 101 | private boolean mSelectedUnavailableNotify = false; |
| 102 | |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 103 | // used to track whether the message waiting indicator is visible, per subscription id. |
| 104 | private ArrayMap<Integer, Boolean> mMwiVisible = new ArrayMap<Integer, Boolean>(); |
| 105 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 106 | /** |
| 107 | * Private constructor (this is a singleton). |
Santos Cordon | f68db2e | 2014-07-02 14:40:44 -0700 | [diff] [blame] | 108 | * @see #init(PhoneGlobals) |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 109 | */ |
| 110 | private NotificationMgr(PhoneGlobals app) { |
| 111 | mApp = app; |
| 112 | mContext = app; |
| 113 | mNotificationManager = |
| 114 | (NotificationManager) app.getSystemService(Context.NOTIFICATION_SERVICE); |
| 115 | mStatusBarManager = |
| 116 | (StatusBarManager) app.getSystemService(Context.STATUS_BAR_SERVICE); |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 117 | mUserManager = (UserManager) app.getSystemService(Context.USER_SERVICE); |
Stuart Scott | dcf40a9 | 2014-12-09 10:45:01 -0800 | [diff] [blame] | 118 | mPhone = app.mCM.getDefaultPhone(); |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 119 | mSubscriptionManager = SubscriptionManager.from(mContext); |
Andrew Lee | d5165b0 | 2014-12-05 15:53:58 -0800 | [diff] [blame] | 120 | mTelecomManager = TelecomManager.from(mContext); |
| 121 | mTelephonyManager = (TelephonyManager) app.getSystemService(Context.TELEPHONY_SERVICE); |
Bryce Lee | 5dc9084 | 2015-08-11 07:57:14 -0700 | [diff] [blame] | 122 | |
| 123 | final String notificationComponent = mContext.getString( |
| 124 | R.string.config_customVoicemailComponent); |
| 125 | |
| 126 | mNotificationComponent = notificationComponent != null |
| 127 | ? ComponentName.unflattenFromString(notificationComponent) : null; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Initialize the singleton NotificationMgr instance. |
| 132 | * |
| 133 | * This is only done once, at startup, from PhoneApp.onCreate(). |
| 134 | * From then on, the NotificationMgr instance is available via the |
| 135 | * PhoneApp's public "notificationMgr" field, which is why there's no |
| 136 | * getInstance() method here. |
| 137 | */ |
| 138 | /* package */ static NotificationMgr init(PhoneGlobals app) { |
| 139 | synchronized (NotificationMgr.class) { |
| 140 | if (sInstance == null) { |
| 141 | sInstance = new NotificationMgr(app); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 142 | } else { |
| 143 | Log.wtf(LOG_TAG, "init() called multiple times! sInstance = " + sInstance); |
| 144 | } |
| 145 | return sInstance; |
| 146 | } |
| 147 | } |
| 148 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 149 | /** The projection to use when querying the phones table */ |
| 150 | static final String[] PHONES_PROJECTION = new String[] { |
| 151 | PhoneLookup.NUMBER, |
| 152 | PhoneLookup.DISPLAY_NAME, |
| 153 | PhoneLookup._ID |
| 154 | }; |
| 155 | |
| 156 | /** |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 157 | * Re-creates the message waiting indicator (voicemail) notification if it is showing. Used to |
| 158 | * refresh the voicemail intent on the indicator when the user changes it via the voicemail |
| 159 | * settings screen. The voicemail notification sound is suppressed. |
| 160 | * |
| 161 | * @param subId The subscription Id. |
| 162 | */ |
| 163 | /* package */ void refreshMwi(int subId) { |
| 164 | // In a single-sim device, subId can be -1 which means "no sub id". In this case we will |
| 165 | // reference the single subid stored in the mMwiVisible map. |
| 166 | if (subId == SubscriptionInfoHelper.NO_SUB_ID) { |
| 167 | if (mMwiVisible.keySet().size() == 1) { |
| 168 | Set<Integer> keySet = mMwiVisible.keySet(); |
| 169 | Iterator<Integer> keyIt = keySet.iterator(); |
| 170 | if (!keyIt.hasNext()) { |
| 171 | return; |
| 172 | } |
| 173 | subId = keyIt.next(); |
| 174 | } |
| 175 | } |
| 176 | if (mMwiVisible.containsKey(subId)) { |
| 177 | boolean mwiVisible = mMwiVisible.get(subId); |
| 178 | if (mwiVisible) { |
| 179 | updateMwi(subId, mwiVisible, false /* enableNotificationSound */); |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 185 | * Updates the message waiting indicator (voicemail) notification. |
| 186 | * |
| 187 | * @param visible true if there are messages waiting |
| 188 | */ |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 189 | /* package */ void updateMwi(int subId, boolean visible) { |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 190 | updateMwi(subId, visible, true /* enableNotificationSound */); |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * Updates the message waiting indicator (voicemail) notification. |
| 195 | * |
| 196 | * @param subId the subId to update. |
| 197 | * @param visible true if there are messages waiting |
| 198 | * @param enableNotificationSound {@code true} if the notification sound should be played. |
| 199 | */ |
| 200 | void updateMwi(int subId, boolean visible, boolean enableNotificationSound) { |
Andrew Lee | a82b820 | 2014-11-21 16:18:28 -0800 | [diff] [blame] | 201 | if (!PhoneGlobals.sVoiceCapable) { |
| 202 | // Do not show the message waiting indicator on devices which are not voice capable. |
| 203 | // These events *should* be blocked at the telephony layer for such devices. |
| 204 | Log.w(LOG_TAG, "Called updateMwi() on non-voice-capable device! Ignoring..."); |
| 205 | return; |
| 206 | } |
| 207 | |
Nancy Chen | 2cf7f29 | 2015-05-15 11:00:10 -0700 | [diff] [blame] | 208 | Phone phone = PhoneGlobals.getPhone(subId); |
| 209 | if (visible && phone != null) { |
| 210 | VoicemailStatusQueryHelper queryHelper = new VoicemailStatusQueryHelper(mContext); |
| 211 | PhoneAccountHandle phoneAccount = PhoneUtils.makePstnPhoneAccountHandle(phone); |
| 212 | if (queryHelper.isNotificationsChannelActive(phoneAccount)) { |
| 213 | Log.v(LOG_TAG, "Notifications channel active for visual voicemail, hiding mwi."); |
| 214 | visible = false; |
| 215 | } |
| 216 | } |
| 217 | |
Yorke Lee | 67a62a2 | 2014-12-15 18:46:17 -0800 | [diff] [blame] | 218 | Log.i(LOG_TAG, "updateMwi(): subId " + subId + " update to " + visible); |
Andrew Lee | f8ad78f | 2014-12-15 16:17:29 -0800 | [diff] [blame] | 219 | mMwiVisible.put(subId, visible); |
| 220 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 221 | if (visible) { |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 222 | if (phone == null) { |
Andrew Lee | d5165b0 | 2014-12-05 15:53:58 -0800 | [diff] [blame] | 223 | Log.w(LOG_TAG, "Found null phone for: " + subId); |
| 224 | return; |
| 225 | } |
| 226 | |
| 227 | SubscriptionInfo subInfo = mSubscriptionManager.getActiveSubscriptionInfo(subId); |
| 228 | if (subInfo == null) { |
| 229 | Log.w(LOG_TAG, "Found null subscription info for: " + subId); |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 230 | return; |
| 231 | } |
| 232 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 233 | int resId = android.R.drawable.stat_notify_voicemail; |
| 234 | |
| 235 | // This Notification can get a lot fancier once we have more |
| 236 | // information about the current voicemail messages. |
| 237 | // (For example, the current voicemail system can't tell |
| 238 | // us the caller-id or timestamp of a message, or tell us the |
| 239 | // message count.) |
| 240 | |
| 241 | // But for now, the UI is ultra-simple: if the MWI indication |
| 242 | // is supposed to be visible, just show a single generic |
| 243 | // notification. |
| 244 | |
| 245 | String notificationTitle = mContext.getString(R.string.notification_voicemail_title); |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 246 | String vmNumber = phone.getVoiceMailNumber(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 247 | if (DBG) log("- got vm number: '" + vmNumber + "'"); |
| 248 | |
Andrew Lee | a82b820 | 2014-11-21 16:18:28 -0800 | [diff] [blame] | 249 | // The voicemail number may be null because: |
| 250 | // (1) This phone has no voicemail number. |
| 251 | // (2) This phone has a voicemail number, but the SIM isn't ready yet. This may |
| 252 | // happen when the device first boots if we get a MWI notification when we |
| 253 | // register on the network before the SIM has loaded. In this case, the |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 254 | // SubscriptionListener in CallNotifier will update this once the SIM is loaded. |
| 255 | if ((vmNumber == null) && !phone.getIccRecordsLoaded()) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 256 | if (DBG) log("- Null vm number: SIM records not loaded (yet)..."); |
Andrew Lee | a82b820 | 2014-11-21 16:18:28 -0800 | [diff] [blame] | 257 | return; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 258 | } |
| 259 | |
Bryce Lee | 5dc9084 | 2015-08-11 07:57:14 -0700 | [diff] [blame] | 260 | Integer vmCount = null; |
| 261 | |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 262 | if (TelephonyCapabilities.supportsVoiceMessageCount(phone)) { |
Bryce Lee | 5dc9084 | 2015-08-11 07:57:14 -0700 | [diff] [blame] | 263 | vmCount = phone.getVoiceMessageCount(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 264 | String titleFormat = mContext.getString(R.string.notification_voicemail_title_count); |
| 265 | notificationTitle = String.format(titleFormat, vmCount); |
| 266 | } |
| 267 | |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 268 | // This pathway only applies to PSTN accounts; only SIMS have subscription ids. |
| 269 | PhoneAccountHandle phoneAccountHandle = PhoneUtils.makePstnPhoneAccountHandle(phone); |
| 270 | |
| 271 | Intent intent; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 272 | String notificationText; |
Bryce Lee | 5dc9084 | 2015-08-11 07:57:14 -0700 | [diff] [blame] | 273 | boolean isSettingsIntent = TextUtils.isEmpty(vmNumber); |
| 274 | |
| 275 | if (isSettingsIntent) { |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 276 | notificationText = mContext.getString( |
| 277 | R.string.notification_voicemail_no_vm_number); |
| 278 | |
| 279 | // If the voicemail number if unknown, instead of calling voicemail, take the user |
| 280 | // to the voicemail settings. |
| 281 | notificationText = mContext.getString( |
| 282 | R.string.notification_voicemail_no_vm_number); |
Andrew Lee | bf07f76 | 2015-04-07 19:05:50 -0700 | [diff] [blame] | 283 | intent = new Intent(VoicemailSettingsActivity.ACTION_ADD_VOICEMAIL); |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 284 | intent.putExtra(SubscriptionInfoHelper.SUB_ID_EXTRA, subId); |
Andrew Lee | bf07f76 | 2015-04-07 19:05:50 -0700 | [diff] [blame] | 285 | intent.setClass(mContext, VoicemailSettingsActivity.class); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 286 | } else { |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 287 | if (mTelephonyManager.getPhoneCount() > 1) { |
| 288 | notificationText = subInfo.getDisplayName().toString(); |
Andrew Lee | d5165b0 | 2014-12-05 15:53:58 -0800 | [diff] [blame] | 289 | } else { |
| 290 | notificationText = String.format( |
| 291 | mContext.getString(R.string.notification_voicemail_text_format), |
| 292 | PhoneNumberUtils.formatNumber(vmNumber)); |
| 293 | } |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 294 | intent = new Intent( |
| 295 | Intent.ACTION_CALL, Uri.fromParts(PhoneAccount.SCHEME_VOICEMAIL, "", |
Jonathan Basseri | 3649bdb | 2015-04-30 22:39:11 -0700 | [diff] [blame] | 296 | null)); |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 297 | intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 300 | PendingIntent pendingIntent = |
| 301 | PendingIntent.getActivity(mContext, subId /* requestCode */, intent, 0); |
Tyler Gunn | 9c1071f | 2014-12-09 10:07:54 -0800 | [diff] [blame] | 302 | Uri ringtoneUri = null; |
| 303 | |
| 304 | if (enableNotificationSound) { |
| 305 | ringtoneUri = VoicemailNotificationSettingsUtil.getRingtoneUri(mPhone); |
| 306 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 307 | |
Nancy Chen | b4a9270 | 2014-12-04 15:57:29 -0800 | [diff] [blame] | 308 | Resources res = mContext.getResources(); |
Jonathan Basseri | c31f1f3 | 2015-05-12 10:13:03 -0700 | [diff] [blame] | 309 | PersistableBundle carrierConfig = PhoneGlobals.getInstance().getCarrierConfigForSubId( |
Jonathan Basseri | 3649bdb | 2015-04-30 22:39:11 -0700 | [diff] [blame] | 310 | mPhone.getSubId()); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 311 | Notification.Builder builder = new Notification.Builder(mContext); |
| 312 | builder.setSmallIcon(resId) |
| 313 | .setWhen(System.currentTimeMillis()) |
Andrew Lee | d5165b0 | 2014-12-05 15:53:58 -0800 | [diff] [blame] | 314 | .setColor(subInfo.getIconTint()) |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 315 | .setContentTitle(notificationTitle) |
| 316 | .setContentText(notificationText) |
| 317 | .setContentIntent(pendingIntent) |
Yorke Lee | acb5f74 | 2014-08-19 09:08:42 -0700 | [diff] [blame] | 318 | .setSound(ringtoneUri) |
Nancy Chen | b4a9270 | 2014-12-04 15:57:29 -0800 | [diff] [blame] | 319 | .setColor(res.getColor(R.color.dialer_theme_color)) |
Jonathan Basseri | 3649bdb | 2015-04-30 22:39:11 -0700 | [diff] [blame] | 320 | .setOngoing(carrierConfig.getBoolean( |
Jonathan Basseri | 9504c6b | 2015-06-04 14:23:32 -0700 | [diff] [blame] | 321 | CarrierConfigManager.KEY_VOICEMAIL_NOTIFICATION_PERSISTENT_BOOL)); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 322 | |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 323 | if (VoicemailNotificationSettingsUtil.isVibrationEnabled(phone)) { |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 324 | builder.setDefaults(Notification.DEFAULT_VIBRATE); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 325 | } |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 326 | |
| 327 | final Notification notification = builder.build(); |
| 328 | List<UserInfo> users = mUserManager.getUsers(true); |
| 329 | for (int i = 0; i < users.size(); i++) { |
Yorke Lee | 047b1f9 | 2014-10-24 10:22:41 -0700 | [diff] [blame] | 330 | final UserInfo user = users.get(i); |
| 331 | final UserHandle userHandle = user.getUserHandle(); |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 332 | if (!mUserManager.hasUserRestriction( |
Yorke Lee | 047b1f9 | 2014-10-24 10:22:41 -0700 | [diff] [blame] | 333 | UserManager.DISALLOW_OUTGOING_CALLS, userHandle) |
Jonathan Basseri | 3649bdb | 2015-04-30 22:39:11 -0700 | [diff] [blame] | 334 | && !user.isManagedProfile()) { |
Bryce Lee | 5dc9084 | 2015-08-11 07:57:14 -0700 | [diff] [blame] | 335 | if (!sendNotificationCustomComponent(vmCount, vmNumber, pendingIntent, |
| 336 | isSettingsIntent)) { |
| 337 | mNotificationManager.notifyAsUser( |
| 338 | Integer.toString(subId) /* tag */, |
| 339 | VOICEMAIL_NOTIFICATION, |
| 340 | notification, |
| 341 | userHandle); |
| 342 | } |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 343 | } |
| 344 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 345 | } else { |
Bryce Lee | 5dc9084 | 2015-08-11 07:57:14 -0700 | [diff] [blame] | 346 | if (!sendNotificationCustomComponent(0, null, null, false)) { |
| 347 | mNotificationManager.cancelAsUser( |
| 348 | Integer.toString(subId) /* tag */, |
| 349 | VOICEMAIL_NOTIFICATION, |
| 350 | UserHandle.ALL); |
| 351 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 352 | } |
| 353 | } |
| 354 | |
| 355 | /** |
Bryce Lee | 5dc9084 | 2015-08-11 07:57:14 -0700 | [diff] [blame] | 356 | * Sends a broadcast with the voicemail notification information to a custom component to |
| 357 | * handle. This method is also used to indicate to the custom component when to clear the |
| 358 | * notification. A pending intent can be passed to the custom component to indicate an action to |
| 359 | * be taken as it would by a notification produced in this class. |
| 360 | * @param count The number of pending voicemail messages to indicate on the notification. A |
| 361 | * Value of 0 is passed here to indicate that the notification should be cleared. |
| 362 | * @param number The voicemail phone number if specified. |
| 363 | * @param pendingIntent The intent that should be passed as the action to be taken. |
| 364 | * @param isSettingsIntent {@code true} to indicate the pending intent is to launch settings. |
| 365 | * otherwise, {@code false} to indicate the intent launches voicemail. |
| 366 | * @return {@code true} if a custom component was notified of the notification. |
| 367 | */ |
| 368 | private boolean sendNotificationCustomComponent(Integer count, String number, |
| 369 | PendingIntent pendingIntent, boolean isSettingsIntent) { |
| 370 | if (mNotificationComponent != null) { |
| 371 | Intent intent = new Intent(); |
| 372 | intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); |
| 373 | intent.setComponent(mNotificationComponent); |
| 374 | intent.setAction(TelephonyManager.ACTION_SHOW_VOICEMAIL_NOTIFICATION); |
| 375 | |
| 376 | if (count != null) { |
| 377 | intent.putExtra(TelephonyManager.EXTRA_NOTIFICATION_COUNT, count); |
| 378 | } |
| 379 | |
| 380 | // Additional information about the voicemail notification beyond the count is only |
| 381 | // present when the count not specified or greater than 0. The value of 0 represents |
| 382 | // clearing the notification, which does not require additional information. |
| 383 | if (count == null || count > 0) { |
| 384 | if (!TextUtils.isEmpty(number)) { |
| 385 | intent.putExtra(TelephonyManager.EXTRA_VOICEMAIL_NUMBER, number); |
| 386 | } |
| 387 | |
| 388 | if (pendingIntent != null) { |
| 389 | intent.putExtra(isSettingsIntent |
| 390 | ? TelephonyManager.EXTRA_LAUNCH_VOICEMAIL_SETTINGS_INTENT |
| 391 | : TelephonyManager.EXTRA_CALL_VOICEMAIL_INTENT, |
| 392 | pendingIntent); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | mContext.sendBroadcast(intent); |
| 397 | return true; |
| 398 | } |
| 399 | |
| 400 | return false; |
| 401 | } |
| 402 | |
| 403 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 404 | * Updates the message call forwarding indicator notification. |
| 405 | * |
| 406 | * @param visible true if there are messages waiting |
| 407 | */ |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 408 | /* package */ void updateCfi(int subId, boolean visible) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 409 | if (DBG) log("updateCfi(): " + visible); |
| 410 | if (visible) { |
| 411 | // If Unconditional Call Forwarding (forward all calls) for VOICE |
| 412 | // is enabled, just show a notification. We'll default to expanded |
| 413 | // view for now, so the there is less confusion about the icon. If |
| 414 | // it is deemed too weird to have CF indications as expanded views, |
| 415 | // then we'll flip the flag back. |
| 416 | |
| 417 | // TODO: We may want to take a look to see if the notification can |
| 418 | // display the target to forward calls to. This will require some |
| 419 | // effort though, since there are multiple layers of messages that |
| 420 | // will need to propagate that information. |
| 421 | |
Andrew Lee | d5165b0 | 2014-12-05 15:53:58 -0800 | [diff] [blame] | 422 | SubscriptionInfo subInfo = mSubscriptionManager.getActiveSubscriptionInfo(subId); |
| 423 | if (subInfo == null) { |
| 424 | Log.w(LOG_TAG, "Found null subscription info for: " + subId); |
| 425 | return; |
| 426 | } |
| 427 | |
| 428 | String notificationTitle; |
| 429 | if (mTelephonyManager.getPhoneCount() > 1) { |
| 430 | notificationTitle = subInfo.getDisplayName().toString(); |
| 431 | } else { |
| 432 | notificationTitle = mContext.getString(R.string.labelCF); |
| 433 | } |
| 434 | |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 435 | Notification.Builder builder = new Notification.Builder(mContext) |
| 436 | .setSmallIcon(R.drawable.stat_sys_phone_call_forward) |
Andrew Lee | d5165b0 | 2014-12-05 15:53:58 -0800 | [diff] [blame] | 437 | .setColor(subInfo.getIconTint()) |
| 438 | .setContentTitle(notificationTitle) |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 439 | .setContentText(mContext.getString(R.string.sum_cfu_enabled_indicator)) |
| 440 | .setShowWhen(false) |
| 441 | .setOngoing(true); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 442 | |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 443 | Intent intent = new Intent(Intent.ACTION_MAIN); |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 444 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 445 | intent.setClassName("com.android.phone", "com.android.phone.CallFeaturesSetting"); |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 446 | SubscriptionInfoHelper.addExtrasToIntent( |
| 447 | intent, mSubscriptionManager.getActiveSubscriptionInfo(subId)); |
| 448 | PendingIntent contentIntent = |
| 449 | PendingIntent.getActivity(mContext, subId /* requestCode */, intent, 0); |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 450 | |
| 451 | List<UserInfo> users = mUserManager.getUsers(true); |
| 452 | for (int i = 0; i < users.size(); i++) { |
Yorke Lee | 3faa594 | 2014-11-05 16:50:04 -0800 | [diff] [blame] | 453 | final UserInfo user = users.get(i); |
| 454 | if (user.isManagedProfile()) { |
| 455 | continue; |
| 456 | } |
| 457 | UserHandle userHandle = user.getUserHandle(); |
Xiaohui Chen | 3105e9a | 2015-10-21 12:27:17 -0700 | [diff] [blame] | 458 | builder.setContentIntent(user.isAdmin() ? contentIntent : null); |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 459 | mNotificationManager.notifyAsUser( |
| 460 | Integer.toString(subId) /* tag */, |
| 461 | CALL_FORWARD_NOTIFICATION, |
| 462 | builder.build(), |
| 463 | userHandle); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 464 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 465 | } else { |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 466 | mNotificationManager.cancelAsUser( |
Andrew Lee | 2fcb6c3 | 2014-12-04 14:52:35 -0800 | [diff] [blame] | 467 | Integer.toString(subId) /* tag */, |
| 468 | CALL_FORWARD_NOTIFICATION, |
| 469 | UserHandle.ALL); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 470 | } |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Shows the "data disconnected due to roaming" notification, which |
| 475 | * appears when you lose data connectivity because you're roaming and |
| 476 | * you have the "data roaming" feature turned off. |
| 477 | */ |
| 478 | /* package */ void showDataDisconnectedRoaming() { |
| 479 | if (DBG) log("showDataDisconnectedRoaming()..."); |
| 480 | |
| 481 | // "Mobile network settings" screen / dialog |
| 482 | Intent intent = new Intent(mContext, com.android.phone.MobileNetworkSettings.class); |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 483 | PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, intent, 0); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 484 | |
| 485 | final CharSequence contentText = mContext.getText(R.string.roaming_reenable_message); |
| 486 | |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 487 | final Notification.Builder builder = new Notification.Builder(mContext) |
| 488 | .setSmallIcon(android.R.drawable.stat_sys_warning) |
| 489 | .setContentTitle(mContext.getText(R.string.roaming)) |
| 490 | .setColor(mContext.getResources().getColor(R.color.dialer_theme_color)) |
| 491 | .setContentText(contentText); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 492 | |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 493 | List<UserInfo> users = mUserManager.getUsers(true); |
| 494 | for (int i = 0; i < users.size(); i++) { |
Yorke Lee | 3faa594 | 2014-11-05 16:50:04 -0800 | [diff] [blame] | 495 | final UserInfo user = users.get(i); |
| 496 | if (user.isManagedProfile()) { |
| 497 | continue; |
| 498 | } |
| 499 | UserHandle userHandle = user.getUserHandle(); |
Xiaohui Chen | 3105e9a | 2015-10-21 12:27:17 -0700 | [diff] [blame] | 500 | builder.setContentIntent(user.isAdmin() ? contentIntent : null); |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 501 | final Notification notif = |
| 502 | new Notification.BigTextStyle(builder).bigText(contentText).build(); |
| 503 | mNotificationManager.notifyAsUser( |
| 504 | null /* tag */, DATA_DISCONNECTED_ROAMING_NOTIFICATION, notif, userHandle); |
| 505 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 506 | } |
| 507 | |
| 508 | /** |
| 509 | * Turns off the "data disconnected due to roaming" notification. |
| 510 | */ |
| 511 | /* package */ void hideDataDisconnectedRoaming() { |
| 512 | if (DBG) log("hideDataDisconnectedRoaming()..."); |
| 513 | mNotificationManager.cancel(DATA_DISCONNECTED_ROAMING_NOTIFICATION); |
| 514 | } |
| 515 | |
| 516 | /** |
| 517 | * Display the network selection "no service" notification |
| 518 | * @param operator is the numeric operator number |
| 519 | */ |
| 520 | private void showNetworkSelection(String operator) { |
| 521 | if (DBG) log("showNetworkSelection(" + operator + ")..."); |
| 522 | |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 523 | Notification.Builder builder = new Notification.Builder(mContext) |
| 524 | .setSmallIcon(android.R.drawable.stat_sys_warning) |
| 525 | .setContentTitle(mContext.getString(R.string.notification_network_selection_title)) |
| 526 | .setContentText( |
| 527 | mContext.getString(R.string.notification_network_selection_text, operator)) |
| 528 | .setShowWhen(false) |
| 529 | .setOngoing(true); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 530 | |
| 531 | // create the target network operators settings intent |
| 532 | Intent intent = new Intent(Intent.ACTION_MAIN); |
| 533 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | |
| 534 | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 535 | // Use NetworkSetting to handle the selection intent |
Wei Liu | be96458 | 2015-08-21 11:57:00 -0700 | [diff] [blame] | 536 | intent.setComponent(new ComponentName( |
| 537 | mContext.getString(R.string.network_operator_settings_package), |
| 538 | mContext.getString(R.string.network_operator_settings_class))); |
Sanket Padawe | 3e1073d | 2015-07-15 18:28:12 -0700 | [diff] [blame] | 539 | intent.putExtra(GsmUmtsOptions.EXTRA_SUB_ID, mPhone.getSubId()); |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 540 | PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, intent, 0); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 541 | |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 542 | List<UserInfo> users = mUserManager.getUsers(true); |
| 543 | for (int i = 0; i < users.size(); i++) { |
Yorke Lee | 3faa594 | 2014-11-05 16:50:04 -0800 | [diff] [blame] | 544 | final UserInfo user = users.get(i); |
| 545 | if (user.isManagedProfile()) { |
| 546 | continue; |
| 547 | } |
| 548 | UserHandle userHandle = user.getUserHandle(); |
Xiaohui Chen | 3105e9a | 2015-10-21 12:27:17 -0700 | [diff] [blame] | 549 | builder.setContentIntent(user.isAdmin() ? contentIntent : null); |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 550 | mNotificationManager.notifyAsUser( |
| 551 | null /* tag */, |
| 552 | SELECTED_OPERATOR_FAIL_NOTIFICATION, |
| 553 | builder.build(), |
| 554 | userHandle); |
| 555 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | /** |
| 559 | * Turn off the network selection "no service" notification |
| 560 | */ |
| 561 | private void cancelNetworkSelection() { |
| 562 | if (DBG) log("cancelNetworkSelection()..."); |
Andrew Lee | 99d0ac2 | 2014-10-10 13:18:04 -0700 | [diff] [blame] | 563 | mNotificationManager.cancelAsUser( |
| 564 | null /* tag */, SELECTED_OPERATOR_FAIL_NOTIFICATION, UserHandle.ALL); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | /** |
| 568 | * Update notification about no service of user selected operator |
| 569 | * |
| 570 | * @param serviceState Phone service state |
| 571 | */ |
| 572 | void updateNetworkSelection(int serviceState) { |
| 573 | if (TelephonyCapabilities.supportsNetworkSelection(mPhone)) { |
Amit Mahajan | a60be87 | 2015-01-15 16:05:08 -0800 | [diff] [blame] | 574 | int subId = mPhone.getSubId(); |
| 575 | if (SubscriptionManager.isValidSubscriptionId(subId)) { |
| 576 | // get the shared preference of network_selection. |
| 577 | // empty is auto mode, otherwise it is the operator alpha name |
| 578 | // in case there is no operator name, check the operator numeric |
| 579 | SharedPreferences sp = |
| 580 | PreferenceManager.getDefaultSharedPreferences(mContext); |
| 581 | String networkSelection = |
Amit Mahajan | c5201f4 | 2015-11-24 15:38:12 -0800 | [diff] [blame] | 582 | sp.getString(Phone.NETWORK_SELECTION_NAME_KEY + subId, ""); |
Amit Mahajan | a60be87 | 2015-01-15 16:05:08 -0800 | [diff] [blame] | 583 | if (TextUtils.isEmpty(networkSelection)) { |
| 584 | networkSelection = |
Amit Mahajan | c5201f4 | 2015-11-24 15:38:12 -0800 | [diff] [blame] | 585 | sp.getString(Phone.NETWORK_SELECTION_KEY + subId, ""); |
Amit Mahajan | a60be87 | 2015-01-15 16:05:08 -0800 | [diff] [blame] | 586 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 587 | |
Amit Mahajan | a60be87 | 2015-01-15 16:05:08 -0800 | [diff] [blame] | 588 | if (DBG) log("updateNetworkSelection()..." + "state = " + |
| 589 | serviceState + " new network " + networkSelection); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 590 | |
Amit Mahajan | a60be87 | 2015-01-15 16:05:08 -0800 | [diff] [blame] | 591 | if (serviceState == ServiceState.STATE_OUT_OF_SERVICE |
| 592 | && !TextUtils.isEmpty(networkSelection)) { |
Hall Liu | 2b846c7 | 2016-02-09 18:21:24 -0800 | [diff] [blame^] | 593 | showNetworkSelection(networkSelection); |
| 594 | mSelectedUnavailableNotify = true; |
Amit Mahajan | a60be87 | 2015-01-15 16:05:08 -0800 | [diff] [blame] | 595 | } else { |
| 596 | if (mSelectedUnavailableNotify) { |
| 597 | cancelNetworkSelection(); |
| 598 | mSelectedUnavailableNotify = false; |
| 599 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 600 | } |
| 601 | } else { |
Amit Mahajan | a60be87 | 2015-01-15 16:05:08 -0800 | [diff] [blame] | 602 | if (DBG) log("updateNetworkSelection()..." + "state = " + |
| 603 | serviceState + " not updating network due to invalid subId " + subId); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 604 | } |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | /* package */ void postTransientNotification(int notifyId, CharSequence msg) { |
| 609 | if (mToast != null) { |
| 610 | mToast.cancel(); |
| 611 | } |
| 612 | |
| 613 | mToast = Toast.makeText(mContext, msg, Toast.LENGTH_LONG); |
| 614 | mToast.show(); |
| 615 | } |
| 616 | |
| 617 | private void log(String msg) { |
| 618 | Log.d(LOG_TAG, msg); |
| 619 | } |
| 620 | } |