Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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.keyguard; |
| 18 | |
Malcolm Chen | 06ec357 | 2019-04-09 15:55:29 -0700 | [diff] [blame] | 19 | import static android.telephony.PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE; |
| 20 | import static android.telephony.PhoneStateListener.LISTEN_NONE; |
| 21 | |
Lucas Dupin | 8968f6a | 2019-08-09 17:41:15 -0700 | [diff] [blame] | 22 | import static com.android.systemui.DejankUtils.whitelistIpcs; |
| 23 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 24 | import android.content.Context; |
| 25 | import android.content.Intent; |
| 26 | import android.content.IntentFilter; |
Dave Mankoff | c4fe6c4 | 2019-11-18 17:03:29 -0500 | [diff] [blame] | 27 | import android.content.res.Resources; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 28 | import android.net.ConnectivityManager; |
| 29 | import android.net.wifi.WifiManager; |
Fabian Kozynski | bf6fef3 | 2019-02-04 09:21:38 -0500 | [diff] [blame] | 30 | import android.os.Handler; |
Malcolm Chen | 06ec357 | 2019-04-09 15:55:29 -0700 | [diff] [blame] | 31 | import android.telephony.PhoneStateListener; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 32 | import android.telephony.ServiceState; |
| 33 | import android.telephony.SubscriptionInfo; |
Malcolm Chen | 06ec357 | 2019-04-09 15:55:29 -0700 | [diff] [blame] | 34 | import android.telephony.SubscriptionManager; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 35 | import android.telephony.TelephonyManager; |
| 36 | import android.text.TextUtils; |
| 37 | import android.util.Log; |
| 38 | |
Fabian Kozynski | d4c84af | 2019-10-07 09:45:50 -0400 | [diff] [blame] | 39 | import androidx.annotation.Nullable; |
Lucas Dupin | 8968f6a | 2019-08-09 17:41:15 -0700 | [diff] [blame] | 40 | import androidx.annotation.VisibleForTesting; |
| 41 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 42 | import com.android.settingslib.WirelessUtils; |
| 43 | import com.android.systemui.Dependency; |
Hyunyoung Song | 8f9d34c | 2019-08-30 14:47:43 -0700 | [diff] [blame] | 44 | import com.android.systemui.R; |
Dave Mankoff | 00e8a2f | 2019-12-18 16:59:49 -0500 | [diff] [blame] | 45 | import com.android.systemui.dagger.qualifiers.Main; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 46 | import com.android.systemui.keyguard.WakefulnessLifecycle; |
| 47 | |
| 48 | import java.util.List; |
| 49 | import java.util.Objects; |
| 50 | |
Dave Mankoff | c4fe6c4 | 2019-11-18 17:03:29 -0500 | [diff] [blame] | 51 | import javax.inject.Inject; |
| 52 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 53 | /** |
| 54 | * Controller that generates text including the carrier names and/or the status of all the SIM |
| 55 | * interfaces in the device. Through a callback, the updates can be retrieved either as a list or |
| 56 | * separated by a given separator {@link CharSequence}. |
| 57 | */ |
| 58 | public class CarrierTextController { |
| 59 | private static final boolean DEBUG = KeyguardConstants.DEBUG; |
| 60 | private static final String TAG = "CarrierTextController"; |
| 61 | |
| 62 | private final boolean mIsEmergencyCallCapable; |
Fabian Kozynski | ba46d1c | 2019-10-03 12:01:38 -0400 | [diff] [blame] | 63 | private final Handler mMainHandler; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 64 | private boolean mTelephonyCapable; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 65 | private boolean mShowMissingSim; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 66 | private boolean mShowAirplaneMode; |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 67 | @VisibleForTesting |
| 68 | protected KeyguardUpdateMonitor mKeyguardUpdateMonitor; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 69 | private WifiManager mWifiManager; |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 70 | private boolean[] mSimErrorState; |
| 71 | private final int mSimSlotsNumber; |
Fabian Kozynski | d4c84af | 2019-10-07 09:45:50 -0400 | [diff] [blame] | 72 | @Nullable // Check for nullability before dispatching |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 73 | private CarrierTextCallback mCarrierTextCallback; |
| 74 | private Context mContext; |
| 75 | private CharSequence mSeparator; |
| 76 | private WakefulnessLifecycle mWakefulnessLifecycle; |
| 77 | private final WakefulnessLifecycle.Observer mWakefulnessObserver = |
| 78 | new WakefulnessLifecycle.Observer() { |
| 79 | @Override |
| 80 | public void onFinishedWakingUp() { |
Fabian Kozynski | d4c84af | 2019-10-07 09:45:50 -0400 | [diff] [blame] | 81 | if (mCarrierTextCallback != null) mCarrierTextCallback.finishedWakingUp(); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public void onStartedGoingToSleep() { |
Fabian Kozynski | d4c84af | 2019-10-07 09:45:50 -0400 | [diff] [blame] | 86 | if (mCarrierTextCallback != null) mCarrierTextCallback.startedGoingToSleep(); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 87 | } |
| 88 | }; |
| 89 | |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 90 | @VisibleForTesting |
| 91 | protected final KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() { |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 92 | @Override |
| 93 | public void onRefreshCarrierInfo() { |
| 94 | if (DEBUG) { |
| 95 | Log.d(TAG, "onRefreshCarrierInfo(), mTelephonyCapable: " |
| 96 | + Boolean.toString(mTelephonyCapable)); |
| 97 | } |
| 98 | updateCarrierText(); |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public void onTelephonyCapable(boolean capable) { |
| 103 | if (DEBUG) { |
| 104 | Log.d(TAG, "onTelephonyCapable() mTelephonyCapable: " |
| 105 | + Boolean.toString(capable)); |
| 106 | } |
| 107 | mTelephonyCapable = capable; |
| 108 | updateCarrierText(); |
| 109 | } |
| 110 | |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 111 | public void onSimStateChanged(int subId, int slotId, int simState) { |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 112 | if (slotId < 0 || slotId >= mSimSlotsNumber) { |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 113 | Log.d(TAG, "onSimStateChanged() - slotId invalid: " + slotId |
| 114 | + " mTelephonyCapable: " + Boolean.toString(mTelephonyCapable)); |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | if (DEBUG) Log.d(TAG, "onSimStateChanged: " + getStatusForIccState(simState)); |
| 119 | if (getStatusForIccState(simState) == CarrierTextController.StatusMode.SimIoError) { |
| 120 | mSimErrorState[slotId] = true; |
| 121 | updateCarrierText(); |
| 122 | } else if (mSimErrorState[slotId]) { |
| 123 | mSimErrorState[slotId] = false; |
| 124 | updateCarrierText(); |
| 125 | } |
| 126 | } |
| 127 | }; |
| 128 | |
Malcolm Chen | 06ec357 | 2019-04-09 15:55:29 -0700 | [diff] [blame] | 129 | private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
| 130 | private PhoneStateListener mPhoneStateListener = new PhoneStateListener() { |
| 131 | @Override |
| 132 | public void onActiveDataSubscriptionIdChanged(int subId) { |
| 133 | mActiveMobileDataSubscription = subId; |
| 134 | if (mKeyguardUpdateMonitor != null) { |
| 135 | updateCarrierText(); |
| 136 | } |
| 137 | } |
| 138 | }; |
| 139 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 140 | /** |
| 141 | * The status of this lock screen. Primarily used for widgets on LockScreen. |
| 142 | */ |
| 143 | private enum StatusMode { |
| 144 | Normal, // Normal case (sim card present, it's not locked) |
| 145 | NetworkLocked, // SIM card is 'network locked'. |
| 146 | SimMissing, // SIM card is missing. |
| 147 | SimMissingLocked, // SIM card is missing, and device isn't provisioned; don't allow access |
| 148 | SimPukLocked, // SIM card is PUK locked because SIM entered wrong too many times |
| 149 | SimLocked, // SIM card is currently locked |
| 150 | SimPermDisabled, // SIM card is permanently disabled due to PUK unlock failure |
| 151 | SimNotReady, // SIM is not ready yet. May never be on devices w/o a SIM. |
| 152 | SimIoError, // SIM card is faulty |
| 153 | SimUnknown // SIM card is unknown |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Controller that provides updates on text with carriers names or SIM status. |
| 158 | * Used by {@link CarrierText}. |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 159 | * |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 160 | * @param separator Separator between different parts of the text |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 161 | */ |
| 162 | public CarrierTextController(Context context, CharSequence separator, boolean showAirplaneMode, |
| 163 | boolean showMissingSim) { |
| 164 | mContext = context; |
Michele | 5dbecd9 | 2019-12-11 17:48:29 -0800 | [diff] [blame] | 165 | mIsEmergencyCallCapable = getTelephonyManager().isVoiceCapable(); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 166 | |
| 167 | mShowAirplaneMode = showAirplaneMode; |
| 168 | mShowMissingSim = showMissingSim; |
| 169 | |
| 170 | mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); |
| 171 | mSeparator = separator; |
| 172 | mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class); |
Malcolm Chen | b908f9c | 2019-11-04 16:26:28 -0800 | [diff] [blame] | 173 | mSimSlotsNumber = getTelephonyManager().getSupportedModemCount(); |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 174 | mSimErrorState = new boolean[mSimSlotsNumber]; |
Fabian Kozynski | ba46d1c | 2019-10-03 12:01:38 -0400 | [diff] [blame] | 175 | mMainHandler = Dependency.get(Dependency.MAIN_HANDLER); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 176 | } |
| 177 | |
Malcolm Chen | b908f9c | 2019-11-04 16:26:28 -0800 | [diff] [blame] | 178 | private TelephonyManager getTelephonyManager() { |
| 179 | return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 180 | } |
| 181 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 182 | /** |
| 183 | * Checks if there are faulty cards. Adds the text depending on the slot of the card |
| 184 | * |
| 185 | * @param text: current carrier text based on the sim state |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 186 | * @param carrierNames names order by subscription order |
| 187 | * @param subOrderBySlot array containing the sub index for each slot ID |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 188 | * @param noSims: whether a valid sim card is inserted |
| 189 | * @return text |
| 190 | */ |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 191 | private CharSequence updateCarrierTextWithSimIoError(CharSequence text, |
| 192 | CharSequence[] carrierNames, int[] subOrderBySlot, boolean noSims) { |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 193 | final CharSequence carrier = ""; |
| 194 | CharSequence carrierTextForSimIOError = getCarrierTextForSimState( |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 195 | TelephonyManager.SIM_STATE_CARD_IO_ERROR, carrier); |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 196 | // mSimErrorState has the state of each sim indexed by slotID. |
Malcolm Chen | b908f9c | 2019-11-04 16:26:28 -0800 | [diff] [blame] | 197 | for (int index = 0; index < getTelephonyManager().getActiveModemCount(); index++) { |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 198 | if (!mSimErrorState[index]) { |
| 199 | continue; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 200 | } |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 201 | // In the case when no sim cards are detected but a faulty card is inserted |
| 202 | // overwrite the text and only show "Invalid card" |
| 203 | if (noSims) { |
| 204 | return concatenate(carrierTextForSimIOError, |
| 205 | getContext().getText( |
| 206 | com.android.internal.R.string.emergency_calls_only), |
| 207 | mSeparator); |
| 208 | } else if (subOrderBySlot[index] != -1) { |
| 209 | int subIndex = subOrderBySlot[index]; |
| 210 | // prepend "Invalid card" when faulty card is inserted in slot 0 or 1 |
| 211 | carrierNames[subIndex] = concatenate(carrierTextForSimIOError, |
| 212 | carrierNames[subIndex], |
| 213 | mSeparator); |
| 214 | } else { |
| 215 | // concatenate "Invalid card" when faulty card is inserted in other slot |
| 216 | text = concatenate(text, carrierTextForSimIOError, mSeparator); |
| 217 | } |
| 218 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 219 | } |
| 220 | return text; |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * Sets the listening status of this controller. If the callback is null, it is set to |
| 225 | * not listening |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 226 | * |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 227 | * @param callback Callback to provide text updates |
| 228 | */ |
| 229 | public void setListening(CarrierTextCallback callback) { |
Malcolm Chen | b908f9c | 2019-11-04 16:26:28 -0800 | [diff] [blame] | 230 | TelephonyManager telephonyManager = getTelephonyManager(); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 231 | if (callback != null) { |
| 232 | mCarrierTextCallback = callback; |
Lucas Dupin | 8968f6a | 2019-08-09 17:41:15 -0700 | [diff] [blame] | 233 | // TODO(b/140034799) |
| 234 | if (whitelistIpcs(() -> ConnectivityManager.from(mContext).isNetworkSupported( |
| 235 | ConnectivityManager.TYPE_MOBILE))) { |
Dave Mankoff | e229469 | 2019-08-14 11:53:13 -0400 | [diff] [blame] | 236 | mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class); |
Fabian Kozynski | ba46d1c | 2019-10-03 12:01:38 -0400 | [diff] [blame] | 237 | // Keyguard update monitor expects callbacks from main thread |
| 238 | mMainHandler.post(() -> { |
| 239 | if (mKeyguardUpdateMonitor != null) { |
| 240 | mKeyguardUpdateMonitor.registerCallback(mCallback); |
| 241 | } |
| 242 | }); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 243 | mWakefulnessLifecycle.addObserver(mWakefulnessObserver); |
Malcolm Chen | 06ec357 | 2019-04-09 15:55:29 -0700 | [diff] [blame] | 244 | telephonyManager.listen(mPhoneStateListener, |
| 245 | LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 246 | } else { |
| 247 | // Don't listen and clear out the text when the device isn't a phone. |
| 248 | mKeyguardUpdateMonitor = null; |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 249 | callback.updateCarrierInfo(new CarrierTextCallbackInfo("", null, false, null)); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 250 | } |
| 251 | } else { |
| 252 | mCarrierTextCallback = null; |
| 253 | if (mKeyguardUpdateMonitor != null) { |
Fabian Kozynski | ba46d1c | 2019-10-03 12:01:38 -0400 | [diff] [blame] | 254 | // Keyguard update monitor expects callbacks from main thread |
| 255 | mMainHandler.post(() -> { |
| 256 | if (mKeyguardUpdateMonitor != null) { |
| 257 | mKeyguardUpdateMonitor.removeCallback(mCallback); |
| 258 | } |
| 259 | }); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 260 | mWakefulnessLifecycle.removeObserver(mWakefulnessObserver); |
| 261 | } |
Malcolm Chen | 06ec357 | 2019-04-09 15:55:29 -0700 | [diff] [blame] | 262 | telephonyManager.listen(mPhoneStateListener, LISTEN_NONE); |
| 263 | } |
| 264 | } |
| 265 | |
Sooraj Sasindran | 0d45da7 | 2019-04-25 15:12:21 -0700 | [diff] [blame] | 266 | protected List<SubscriptionInfo> getSubscriptionInfo() { |
Malcolm Chen | 5c63b51 | 2019-08-13 13:24:07 -0700 | [diff] [blame] | 267 | return mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(false); |
Sooraj Sasindran | 0d45da7 | 2019-04-25 15:12:21 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 270 | protected void updateCarrierText() { |
| 271 | boolean allSimsMissing = true; |
| 272 | boolean anySimReadyAndInService = false; |
| 273 | CharSequence displayText = null; |
Sooraj Sasindran | 0d45da7 | 2019-04-25 15:12:21 -0700 | [diff] [blame] | 274 | List<SubscriptionInfo> subs = getSubscriptionInfo(); |
Malcolm Chen | 06ec357 | 2019-04-09 15:55:29 -0700 | [diff] [blame] | 275 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 276 | final int numSubs = subs.size(); |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 277 | final int[] subsIds = new int[numSubs]; |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 278 | // This array will contain in position i, the index of subscription in slot ID i. |
| 279 | // -1 if no subscription in that slot |
| 280 | final int[] subOrderBySlot = new int[mSimSlotsNumber]; |
| 281 | for (int i = 0; i < mSimSlotsNumber; i++) { |
| 282 | subOrderBySlot[i] = -1; |
| 283 | } |
| 284 | final CharSequence[] carrierNames = new CharSequence[numSubs]; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 285 | if (DEBUG) Log.d(TAG, "updateCarrierText(): " + numSubs); |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 286 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 287 | for (int i = 0; i < numSubs; i++) { |
| 288 | int subId = subs.get(i).getSubscriptionId(); |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 289 | carrierNames[i] = ""; |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 290 | subsIds[i] = subId; |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 291 | subOrderBySlot[subs.get(i).getSimSlotIndex()] = i; |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 292 | int simState = mKeyguardUpdateMonitor.getSimState(subId); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 293 | CharSequence carrierName = subs.get(i).getCarrierName(); |
| 294 | CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName); |
| 295 | if (DEBUG) { |
| 296 | Log.d(TAG, "Handling (subId=" + subId + "): " + simState + " " + carrierName); |
| 297 | } |
| 298 | if (carrierTextForSimState != null) { |
| 299 | allSimsMissing = false; |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 300 | carrierNames[i] = carrierTextForSimState; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 301 | } |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 302 | if (simState == TelephonyManager.SIM_STATE_READY) { |
Bonian Chen | a7e9e8c | 2019-06-02 23:59:31 +0000 | [diff] [blame] | 303 | ServiceState ss = mKeyguardUpdateMonitor.mServiceStates.get(subId); |
SongFerngWang | 2670cba | 2019-12-23 19:21:14 +0800 | [diff] [blame] | 304 | if (ss != null && ss.getDataRegistrationState() == ServiceState.STATE_IN_SERVICE) { |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 305 | // hack for WFC (IWLAN) not turning off immediately once |
| 306 | // Wi-Fi is disassociated or disabled |
Bonian Chen | a7e9e8c | 2019-06-02 23:59:31 +0000 | [diff] [blame] | 307 | if (ss.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 308 | || (mWifiManager.isWifiEnabled() |
| 309 | && mWifiManager.getConnectionInfo() != null |
| 310 | && mWifiManager.getConnectionInfo().getBSSID() != null)) { |
| 311 | if (DEBUG) { |
Bonian Chen | a7e9e8c | 2019-06-02 23:59:31 +0000 | [diff] [blame] | 312 | Log.d(TAG, "SIM ready and in service: subId=" + subId + ", ss=" + ss); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 313 | } |
| 314 | anySimReadyAndInService = true; |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | } |
Fabian Kozynski | 0f49f20 | 2019-08-29 09:47:07 -0400 | [diff] [blame] | 319 | // Only create "No SIM card" if no cards with CarrierName && no wifi when some sim is READY |
| 320 | // This condition will also be true always when numSubs == 0 |
| 321 | if (allSimsMissing && !anySimReadyAndInService) { |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 322 | if (numSubs != 0) { |
| 323 | // Shows "No SIM card | Emergency calls only" on devices that are voice-capable. |
| 324 | // This depends on mPlmn containing the text "Emergency calls only" when the radio |
| 325 | // has some connectivity. Otherwise, it should be null or empty and just show |
| 326 | // "No SIM card" |
| 327 | // Grab the first subscripton, because they all should contain the emergency text, |
| 328 | // described above. |
| 329 | displayText = makeCarrierStringOnEmergencyCapable( |
| 330 | getMissingSimMessage(), subs.get(0).getCarrierName()); |
| 331 | } else { |
| 332 | // We don't have a SubscriptionInfo to get the emergency calls only from. |
| 333 | // Grab it from the old sticky broadcast if possible instead. We can use it |
| 334 | // here because no subscriptions are active, so we don't have |
| 335 | // to worry about MSIM clashing. |
| 336 | CharSequence text = |
| 337 | getContext().getText(com.android.internal.R.string.emergency_calls_only); |
| 338 | Intent i = getContext().registerReceiver(null, |
Meng Wang | 57f5655 | 2020-01-17 16:58:40 -0800 | [diff] [blame] | 339 | new IntentFilter(TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED)); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 340 | if (i != null) { |
| 341 | String spn = ""; |
| 342 | String plmn = ""; |
Meng Wang | 57f5655 | 2020-01-17 16:58:40 -0800 | [diff] [blame] | 343 | if (i.getBooleanExtra(TelephonyManager.EXTRA_SHOW_SPN, false)) { |
| 344 | spn = i.getStringExtra(TelephonyManager.EXTRA_SPN); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 345 | } |
Meng Wang | 57f5655 | 2020-01-17 16:58:40 -0800 | [diff] [blame] | 346 | if (i.getBooleanExtra(TelephonyManager.EXTRA_SHOW_PLMN, false)) { |
| 347 | plmn = i.getStringExtra(TelephonyManager.EXTRA_PLMN); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 348 | } |
| 349 | if (DEBUG) Log.d(TAG, "Getting plmn/spn sticky brdcst " + plmn + "/" + spn); |
| 350 | if (Objects.equals(plmn, spn)) { |
| 351 | text = plmn; |
| 352 | } else { |
| 353 | text = concatenate(plmn, spn, mSeparator); |
| 354 | } |
| 355 | } |
| 356 | displayText = makeCarrierStringOnEmergencyCapable(getMissingSimMessage(), text); |
| 357 | } |
| 358 | } |
| 359 | |
Fabian Kozynski | c3d06f3 | 2019-07-31 14:18:41 -0400 | [diff] [blame] | 360 | if (TextUtils.isEmpty(displayText)) displayText = joinNotEmpty(mSeparator, carrierNames); |
| 361 | |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 362 | displayText = updateCarrierTextWithSimIoError(displayText, carrierNames, subOrderBySlot, |
| 363 | allSimsMissing); |
Fabian Kozynski | c3d06f3 | 2019-07-31 14:18:41 -0400 | [diff] [blame] | 364 | |
Fabian Kozynski | b38edbb | 2019-04-12 12:20:13 -0400 | [diff] [blame] | 365 | boolean airplaneMode = false; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 366 | // APM (airplane mode) != no carrier state. There are carrier services |
| 367 | // (e.g. WFC = Wi-Fi calling) which may operate in APM. |
| 368 | if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) { |
| 369 | displayText = getAirplaneModeMessage(); |
Fabian Kozynski | b38edbb | 2019-04-12 12:20:13 -0400 | [diff] [blame] | 370 | airplaneMode = true; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 371 | } |
| 372 | |
Fabian Kozynski | bf6fef3 | 2019-02-04 09:21:38 -0500 | [diff] [blame] | 373 | final CarrierTextCallbackInfo info = new CarrierTextCallbackInfo( |
| 374 | displayText, |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 375 | carrierNames, |
| 376 | !allSimsMissing, |
Fabian Kozynski | b38edbb | 2019-04-12 12:20:13 -0400 | [diff] [blame] | 377 | subsIds, |
| 378 | airplaneMode); |
Fabian Kozynski | b176f42 | 2019-02-05 09:36:59 -0500 | [diff] [blame] | 379 | postToCallback(info); |
| 380 | } |
| 381 | |
| 382 | @VisibleForTesting |
| 383 | protected void postToCallback(CarrierTextCallbackInfo info) { |
Fabian Kozynski | 48343c3 | 2019-02-07 10:28:50 -0500 | [diff] [blame] | 384 | final CarrierTextCallback callback = mCarrierTextCallback; |
| 385 | if (callback != null) { |
Fabian Kozynski | ba46d1c | 2019-10-03 12:01:38 -0400 | [diff] [blame] | 386 | mMainHandler.post(() -> callback.updateCarrierInfo(info)); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 387 | } |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | private Context getContext() { |
| 391 | return mContext; |
| 392 | } |
| 393 | |
| 394 | private String getMissingSimMessage() { |
| 395 | return mShowMissingSim && mTelephonyCapable |
| 396 | ? getContext().getString(R.string.keyguard_missing_sim_message_short) : ""; |
| 397 | } |
| 398 | |
| 399 | private String getAirplaneModeMessage() { |
| 400 | return mShowAirplaneMode |
| 401 | ? getContext().getString(R.string.airplane_mode) : ""; |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Top-level function for creating carrier text. Makes text based on simState, PLMN |
| 406 | * and SPN as well as device capabilities, such as being emergency call capable. |
| 407 | * |
| 408 | * @return Carrier text if not in missing state, null otherwise. |
| 409 | */ |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 410 | private CharSequence getCarrierTextForSimState(int simState, CharSequence text) { |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 411 | CharSequence carrierText = null; |
| 412 | CarrierTextController.StatusMode status = getStatusForIccState(simState); |
| 413 | switch (status) { |
| 414 | case Normal: |
| 415 | carrierText = text; |
| 416 | break; |
| 417 | |
| 418 | case SimNotReady: |
| 419 | // Null is reserved for denoting missing, in this case we have nothing to display. |
| 420 | carrierText = ""; // nothing to display yet. |
| 421 | break; |
| 422 | |
| 423 | case NetworkLocked: |
| 424 | carrierText = makeCarrierStringOnEmergencyCapable( |
| 425 | mContext.getText(R.string.keyguard_network_locked_message), text); |
| 426 | break; |
| 427 | |
| 428 | case SimMissing: |
| 429 | carrierText = null; |
| 430 | break; |
| 431 | |
| 432 | case SimPermDisabled: |
| 433 | carrierText = makeCarrierStringOnEmergencyCapable( |
| 434 | getContext().getText( |
| 435 | R.string.keyguard_permanent_disabled_sim_message_short), |
| 436 | text); |
| 437 | break; |
| 438 | |
| 439 | case SimMissingLocked: |
| 440 | carrierText = null; |
| 441 | break; |
| 442 | |
| 443 | case SimLocked: |
Fabian Kozynski | 2fb343a | 2019-05-08 16:06:51 -0400 | [diff] [blame] | 444 | carrierText = makeCarrierStringOnLocked( |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 445 | getContext().getText(R.string.keyguard_sim_locked_message), |
| 446 | text); |
| 447 | break; |
| 448 | |
| 449 | case SimPukLocked: |
Fabian Kozynski | 2fb343a | 2019-05-08 16:06:51 -0400 | [diff] [blame] | 450 | carrierText = makeCarrierStringOnLocked( |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 451 | getContext().getText(R.string.keyguard_sim_puk_locked_message), |
| 452 | text); |
| 453 | break; |
| 454 | case SimIoError: |
| 455 | carrierText = makeCarrierStringOnEmergencyCapable( |
| 456 | getContext().getText(R.string.keyguard_sim_error_message_short), |
| 457 | text); |
| 458 | break; |
| 459 | case SimUnknown: |
| 460 | carrierText = null; |
| 461 | break; |
| 462 | } |
| 463 | |
| 464 | return carrierText; |
| 465 | } |
| 466 | |
| 467 | /* |
| 468 | * Add emergencyCallMessage to carrier string only if phone supports emergency calls. |
| 469 | */ |
| 470 | private CharSequence makeCarrierStringOnEmergencyCapable( |
| 471 | CharSequence simMessage, CharSequence emergencyCallMessage) { |
| 472 | if (mIsEmergencyCallCapable) { |
| 473 | return concatenate(simMessage, emergencyCallMessage, mSeparator); |
| 474 | } |
| 475 | return simMessage; |
| 476 | } |
| 477 | |
Fabian Kozynski | 2fb343a | 2019-05-08 16:06:51 -0400 | [diff] [blame] | 478 | /* |
| 479 | * Add "SIM card is locked" in parenthesis after carrier name, so it is easily associated in |
| 480 | * DSDS |
| 481 | */ |
| 482 | private CharSequence makeCarrierStringOnLocked(CharSequence simMessage, |
| 483 | CharSequence carrierName) { |
| 484 | final boolean simMessageValid = !TextUtils.isEmpty(simMessage); |
| 485 | final boolean carrierNameValid = !TextUtils.isEmpty(carrierName); |
| 486 | if (simMessageValid && carrierNameValid) { |
| 487 | return mContext.getString(R.string.keyguard_carrier_name_with_sim_locked_template, |
| 488 | carrierName, simMessage); |
| 489 | } else if (simMessageValid) { |
| 490 | return simMessage; |
| 491 | } else if (carrierNameValid) { |
| 492 | return carrierName; |
| 493 | } else { |
| 494 | return ""; |
| 495 | } |
| 496 | } |
| 497 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 498 | /** |
| 499 | * Determine the current status of the lock screen given the SIM state and other stuff. |
| 500 | */ |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 501 | private CarrierTextController.StatusMode getStatusForIccState(int simState) { |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 502 | final boolean missingAndNotProvisioned = |
Dave Mankoff | e229469 | 2019-08-14 11:53:13 -0400 | [diff] [blame] | 503 | !Dependency.get(KeyguardUpdateMonitor.class).isDeviceProvisioned() |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 504 | && (simState == TelephonyManager.SIM_STATE_ABSENT |
| 505 | || simState == TelephonyManager.SIM_STATE_PERM_DISABLED); |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 506 | |
| 507 | // Assume we're NETWORK_LOCKED if not provisioned |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 508 | simState = missingAndNotProvisioned ? TelephonyManager.SIM_STATE_NETWORK_LOCKED : simState; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 509 | switch (simState) { |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 510 | case TelephonyManager.SIM_STATE_ABSENT: |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 511 | return CarrierTextController.StatusMode.SimMissing; |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 512 | case TelephonyManager.SIM_STATE_NETWORK_LOCKED: |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 513 | return CarrierTextController.StatusMode.SimMissingLocked; |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 514 | case TelephonyManager.SIM_STATE_NOT_READY: |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 515 | return CarrierTextController.StatusMode.SimNotReady; |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 516 | case TelephonyManager.SIM_STATE_PIN_REQUIRED: |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 517 | return CarrierTextController.StatusMode.SimLocked; |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 518 | case TelephonyManager.SIM_STATE_PUK_REQUIRED: |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 519 | return CarrierTextController.StatusMode.SimPukLocked; |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 520 | case TelephonyManager.SIM_STATE_READY: |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 521 | return CarrierTextController.StatusMode.Normal; |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 522 | case TelephonyManager.SIM_STATE_PERM_DISABLED: |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 523 | return CarrierTextController.StatusMode.SimPermDisabled; |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 524 | case TelephonyManager.SIM_STATE_UNKNOWN: |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 525 | return CarrierTextController.StatusMode.SimUnknown; |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 526 | case TelephonyManager.SIM_STATE_CARD_IO_ERROR: |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 527 | return CarrierTextController.StatusMode.SimIoError; |
| 528 | } |
| 529 | return CarrierTextController.StatusMode.SimUnknown; |
| 530 | } |
| 531 | |
| 532 | private static CharSequence concatenate(CharSequence plmn, CharSequence spn, |
| 533 | CharSequence separator) { |
| 534 | final boolean plmnValid = !TextUtils.isEmpty(plmn); |
| 535 | final boolean spnValid = !TextUtils.isEmpty(spn); |
| 536 | if (plmnValid && spnValid) { |
| 537 | return new StringBuilder().append(plmn).append(separator).append(spn).toString(); |
| 538 | } else if (plmnValid) { |
| 539 | return plmn; |
| 540 | } else if (spnValid) { |
| 541 | return spn; |
| 542 | } else { |
| 543 | return ""; |
| 544 | } |
| 545 | } |
| 546 | |
Fabian Kozynski | 00d02f1 | 2019-04-15 09:48:30 -0400 | [diff] [blame] | 547 | /** |
| 548 | * Joins the strings in a sequence using a separator. Empty strings are discarded with no extra |
| 549 | * separator added so there are no extra separators that are not needed. |
| 550 | */ |
| 551 | private static CharSequence joinNotEmpty(CharSequence separator, CharSequence[] sequences) { |
| 552 | int length = sequences.length; |
| 553 | if (length == 0) return ""; |
| 554 | StringBuilder sb = new StringBuilder(); |
| 555 | for (int i = 0; i < length; i++) { |
| 556 | if (!TextUtils.isEmpty(sequences[i])) { |
| 557 | if (!TextUtils.isEmpty(sb)) { |
| 558 | sb.append(separator); |
| 559 | } |
| 560 | sb.append(sequences[i]); |
| 561 | } |
| 562 | } |
| 563 | return sb.toString(); |
| 564 | } |
| 565 | |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 566 | private static List<CharSequence> append(List<CharSequence> list, CharSequence string) { |
| 567 | if (!TextUtils.isEmpty(string)) { |
| 568 | list.add(string); |
| 569 | } |
| 570 | return list; |
| 571 | } |
| 572 | |
Jayachandran C | f5436a6 | 2019-11-08 18:22:45 -0800 | [diff] [blame] | 573 | private CharSequence getCarrierHelpTextForSimState(int simState, |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 574 | String plmn, String spn) { |
| 575 | int carrierHelpTextId = 0; |
| 576 | CarrierTextController.StatusMode status = getStatusForIccState(simState); |
| 577 | switch (status) { |
| 578 | case NetworkLocked: |
| 579 | carrierHelpTextId = R.string.keyguard_instructions_when_pattern_disabled; |
| 580 | break; |
| 581 | |
| 582 | case SimMissing: |
| 583 | carrierHelpTextId = R.string.keyguard_missing_sim_instructions_long; |
| 584 | break; |
| 585 | |
| 586 | case SimPermDisabled: |
| 587 | carrierHelpTextId = R.string.keyguard_permanent_disabled_sim_instructions; |
| 588 | break; |
| 589 | |
| 590 | case SimMissingLocked: |
| 591 | carrierHelpTextId = R.string.keyguard_missing_sim_instructions; |
| 592 | break; |
| 593 | |
| 594 | case Normal: |
| 595 | case SimLocked: |
| 596 | case SimPukLocked: |
| 597 | break; |
| 598 | } |
| 599 | |
| 600 | return mContext.getText(carrierHelpTextId); |
| 601 | } |
| 602 | |
Dave Mankoff | c4fe6c4 | 2019-11-18 17:03:29 -0500 | [diff] [blame] | 603 | public static class Builder { |
| 604 | private final Context mContext; |
| 605 | private final String mSeparator; |
| 606 | private boolean mShowAirplaneMode; |
| 607 | private boolean mShowMissingSim; |
| 608 | |
| 609 | @Inject |
Dave Mankoff | 00e8a2f | 2019-12-18 16:59:49 -0500 | [diff] [blame] | 610 | public Builder(Context context, @Main Resources resources) { |
Dave Mankoff | c4fe6c4 | 2019-11-18 17:03:29 -0500 | [diff] [blame] | 611 | mContext = context; |
| 612 | mSeparator = resources.getString( |
| 613 | com.android.internal.R.string.kg_text_message_separator); |
| 614 | } |
| 615 | |
| 616 | |
| 617 | public Builder setShowAirplaneMode(boolean showAirplaneMode) { |
| 618 | mShowAirplaneMode = showAirplaneMode; |
| 619 | return this; |
| 620 | } |
| 621 | |
| 622 | public Builder setShowMissingSim(boolean showMissingSim) { |
| 623 | mShowMissingSim = showMissingSim; |
| 624 | return this; |
| 625 | } |
| 626 | |
| 627 | public CarrierTextController build() { |
| 628 | return new CarrierTextController( |
| 629 | mContext, mSeparator, mShowAirplaneMode, mShowMissingSim); |
| 630 | } |
| 631 | } |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 632 | /** |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 633 | * Data structure for passing information to CarrierTextController subscribers |
| 634 | */ |
| 635 | public static final class CarrierTextCallbackInfo { |
| 636 | public final CharSequence carrierText; |
| 637 | public final CharSequence[] listOfCarriers; |
| 638 | public final boolean anySimReady; |
| 639 | public final int[] subscriptionIds; |
Fabian Kozynski | b38edbb | 2019-04-12 12:20:13 -0400 | [diff] [blame] | 640 | public boolean airplaneMode; |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 641 | |
Fabian Kozynski | bf6fef3 | 2019-02-04 09:21:38 -0500 | [diff] [blame] | 642 | @VisibleForTesting |
| 643 | public CarrierTextCallbackInfo(CharSequence carrierText, CharSequence[] listOfCarriers, |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 644 | boolean anySimReady, int[] subscriptionIds) { |
Fabian Kozynski | b38edbb | 2019-04-12 12:20:13 -0400 | [diff] [blame] | 645 | this(carrierText, listOfCarriers, anySimReady, subscriptionIds, false); |
| 646 | } |
| 647 | |
| 648 | @VisibleForTesting |
| 649 | public CarrierTextCallbackInfo(CharSequence carrierText, CharSequence[] listOfCarriers, |
| 650 | boolean anySimReady, int[] subscriptionIds, boolean airplaneMode) { |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 651 | this.carrierText = carrierText; |
| 652 | this.listOfCarriers = listOfCarriers; |
| 653 | this.anySimReady = anySimReady; |
| 654 | this.subscriptionIds = subscriptionIds; |
Fabian Kozynski | b38edbb | 2019-04-12 12:20:13 -0400 | [diff] [blame] | 655 | this.airplaneMode = airplaneMode; |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 656 | } |
| 657 | } |
| 658 | |
| 659 | /** |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 660 | * Callback to communicate to Views |
| 661 | */ |
| 662 | public interface CarrierTextCallback { |
| 663 | /** |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 664 | * Provides updated carrier information. |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 665 | */ |
Fabian Kozynski | 1823f11 | 2019-01-18 11:43:29 -0500 | [diff] [blame] | 666 | default void updateCarrierInfo(CarrierTextCallbackInfo info) {}; |
Fabian Kozynski | 02941af | 2019-01-17 17:57:37 -0500 | [diff] [blame] | 667 | |
| 668 | /** |
| 669 | * Notifies the View that the device is going to sleep |
| 670 | */ |
| 671 | default void startedGoingToSleep() {}; |
| 672 | |
| 673 | /** |
| 674 | * Notifies the View that the device finished waking up |
| 675 | */ |
| 676 | default void finishedWakingUp() {}; |
| 677 | } |
| 678 | } |