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